pyinitials

ISC License

Downloads
109
Stars
2

PyInitials, because GvR is shorter than Guido van Rossum

from pyinitials import initials

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

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 [email protected]') # 'JD'

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

initials('[email protected]') # '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

Package Rankings
Top 24.69% on Pypi.org
Badges
Extracted from project README
CI BCH compliance
Related Projects