Skip to main content

personnummer Build Status

Validate Swedish personal identity numbers. Version 3+ only supports Python 3.

Installation

pip install personnummer

or

pip3 install personnummer

Examples

  • All examples that uses personnummer.Personnumer([params]), can be replaced with personnummer.parse([params]).

Validation

from personnummer import personnummer

personnummer.valid("8507099805")
# => True

personnummer.valid("198507099805")
# => True

Format

from personnummer import personnummer

# Short format
pn = personnummer.Personnummer(8507099805)
pn.format()
# => '850709-9805'

# Long format
pn = personnummer.Personnummer('8507099805')
pn.format(True)
# => '198507099805'

Get Date

New in version 3.2.0

from personnummer import personnummer

pn = personnummer.Personnummer('19121212+1212')
pn.get_date()
# => datetime.date(1912, 12, 12)

Get Age

from personnummer import personnummer

pn = personnummer.Personnummer("19121212+1212")
pn.get_age()
# => 106

See personnummer/tests/test_personnummer.py for more examples.

License

MIT

Metadata

Release files for personnummer 3.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for personnummer 3.2.1
File Size Uploaded
personnummer-3.2.1.tar.gz 5.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for personnummer 3.2.1
File Interpreter ABI Platform
personnummer-3.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 12.8 kB

Release files / personnummer-3.2.1.tar.gz

Download URL personnummer-3.2.1.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
5b319741d8b326ab4359427e1fa6b03101d48b19efc9d1a53cf17515fb4cc8b4
BLAKE2b-256 checksum
How to use checksums
eec5d9cbf6f8d368ed175240e757888f4c9ebe443b6cf36b11bee72d2bf4c51b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release files / personnummer-3.2.1-py3-none-any.whl

Download URL personnummer-3.2.1-py3-none-any.whl
Size 7.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
15d6c42f87e84bb4a486a6076d29f4d823346e4b0545e3ff6af92e6e06bd05ed
BLAKE2b-256 checksum
How to use checksums
2258cf8e6dd8e25ee52c7db20f9a8da1f3e492ec28a7ae57c30533f83a6c2dff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release history Release notifications | RSS feed

This release

3.2.1 This release

2 release files

3.2.0

2 release files

3.0.6

2 release files

3.0.4

2 release files

3.0.3

2 release files

3.0.2

1 release file

3.0.1

1 release file

3.0.0

1 release file

1.1.0

3 release files

1.0.2

1 release file

1.0.1

3 release files

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page