Skip to main content

No project description provided

Project description

PyInitials, because GvR is shorter than Guido van Rossum

from pyinitials import initials

print(initials('Guido van Rossum')) # prints "GvR"

CI BCH compliance

This project is a Python clone of the JavaScript initials package.

Installation

Install from PyPi, for example with Poetry:

poetry add pyinitials

Usage

from pyinitials import initials, find, parse, add_to

initials('John Doe') # 'JD'

initials(['John Doe', 'Robert Roe']) # ['JD', 'RR']

# alias for initials('John Doe')
find('John Doe') # 'JD'

parse('John Doe') # Parts(name='John Doe', initials='JD', email=None)

# add initials to name(s)
add_to('John Doe') # 'John Doe (JD)'

# Pass existing initials for names
initials(['John Doe', 'Jane Dane'], existing={'John Doe': 'JD'}) # ['JD', 'JDa']

Notes

Preffered initials can be passed in (JD), e.g.

initials('John Doe (JoDo)') # 'JoDo'

If a name contains an email, it gets ignored when calculating initials

initials('John Doe joe@example.com') # 'JD'

If a name is an email, the domain part gets ignored

initials('joe@example.com') # 'jo'

When passing an Array of names, duplicates of initials are avoided

initials(['John Doe', 'Jane Dane']) # ['JDo', 'JDa']

Build and test

Install dependencies:

poetry install

Run the unit-tests:

poetry run pytest

LICENSE

ISC

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyinitials-1.0.0.tar.gz (4.6 kB view hashes)

Uploaded Source

Built Distribution

pyinitials-1.0.0-py3-none-any.whl (4.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page