Skip to content

Generation

You may not be interested in parsing an MPAN, but rather would just like a way to reliably generate a valid one a few thousand times. For that, this library has a provider fo both the Faker and Mimesis libraries:

Faker

Faker support is available via the optional extra faker, so you must install mpan like this to use it:

1
$ pip install mpan[faker]

Example

1
2
3
4
5
6
7
8
9
from faker import Faker

from mpan.generation.faker import MPANProvider


fake = Faker()
fake.add_provider(MPANProvider)

print(fake.mpan())

Mimesis

Mimesis support is available via the optional extra mimesis, so you must install mpan like this to use it:

1
$ pip install mpan[mimesis]

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
from mimesis import Generic
from mimesis.locales import Locale

from mpan.generation.mimesis import MPANProvider


generic = Generic(locale=Locale.DEFAULT)
generic.add_provider(MPANProvider)

print(generic.mpan.generate())