Skip to main content

Takes a full human name and splits it into individual parts

Project description

[![Build Status](](

nameparts is a Python module that I wrote to address a problem splitting full names into individual parts (first, middle, last, etc.)

You can use it like this:

>>> from nameparts import Name
>>> n = Name("Thurston Howel III")
>>> n.first_name
>>> n.last_name
>>> n.as_dict
{'first_name': 'Thurston', 'last_name': 'Howel', \
  'middle_name': None, 'suffix': None, 'generation': 'III', \
  'salutation': None}
>>> n = Name("Smith, John Paul")
>>> n.first_name
>>> n.last_name
>>> n.middle_name

If you suspect you may see more than one name in a given field (i.e. separated by a/k/a) you can use MultiName:

>>> from nameparts import MultiName
>>> names = MultiName("Bruce Wayne a/k/a Batman")
>>> names
[<Name: 'Bruce Wayne'>, <Name: 'Batman'>]
>>> [n.as_dict for n in names]
[{'last_name': 'Wayne', 'salutation': None, 'first_name': 'Bruce', 'suffix': None,
  'generation': None, 'middle_name': None, 'aliases': None},
 {'last_name': '', 'salutation': None, 'first_name': 'Batman', 'suffix': None,
  'generation': None, 'middle_name': None, 'aliases': None}]

MultiName automatically uses the string ‘a/k/a’ to split names, but you can provide an optional splitter argument to override that:

>>> from nameparts import MultiName
>>> names = MultiName("Tony Stark | Ironman | Stark, Tony", splitter="|")
>>> names
[<Name: 'Tony Stark'>, <Name: 'Ironman'>, <Name: 'Tony Stark'>]


From source:

python install

via pip:

pip install nameparts

nameparts runs on CPython 2.6, 2.7, 3.2 and PyPy


nameparts is released under the BSD license.


Any of the above are welcome. Contact me at the email address in my profile.

Project details

Download files

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

Files for nameparts, version 0.5.8
Filename, size File type Python version Upload date Hashes
Filename, size nameparts-0.5.8.tar.gz (6.4 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page