faker.providers.barcode

class faker.providers.barcode.Provider(generator)

Bases: faker.providers.BaseProvider

ean(length=13, prefixes=())

Generate an EAN barcode of the specified length.

The value of length can only be 8 or 13 (default) which will create an EAN-8 or an EAN-13 barcode respectively.

If prefixes are specified, the result will begin with one of the sequence in prefixes

Examples:
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.ean(length=13)
...
'6604876475937'
'8242194892418'
'1578156593879'
'7840801609759'
'3513933287112'
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.ean(length=8)
...
'66048763'
'47593824'
'42194897'
'24115780'
'15659385'
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.ean(prefixes=('00', ))
...
'0004876475931'
'0019489241156'
'0065938778407'
'0016097535134'
'0028711587146'
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.ean(prefixes=('45', '49'))
...
'4904876475930'
'4519489241157'
'4965938778406'
'4916097535133'
'4928711587145'
ean13(prefixes=())

Generate an EAN-13 barcode.

If prefixes are specified, the result will begin with one of the sequence in prefixes.

This method uses ean() under the hood with the length argument explicitly set to 13.

Note

Codes starting with a leading zero are treated specially in some barcode readers.

For more information about compatibility with UPC-A codes, see en_US.ean13()

Examples:
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.ean13()
...
'6604876475937'
'8242194892418'
'1578156593879'
'7840801609759'
'3513933287112'
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.ean13(prefixes=('00', ))
...
'0004876475931'
'0019489241156'
'0065938778407'
'0016097535134'
'0028711587146'
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.ean13(prefixes=('45', '49'))
...
'4904876475930'
'4519489241157'
'4965938778406'
'4916097535133'
'4928711587145'
ean8(prefixes=())

Generate an EAN-8 barcode.

This method uses ean() under the hood with the length argument explicitly set to 8.

If prefixes are specified, the result will begin with one of the sequence in prefixes

Examples:
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.ean8()
...
'66048763'
'47593824'
'42194897'
'24115780'
'15659385'
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.ean8(prefixes=('00', ))
...
'00048767'
'00593823'
'00489249'
'00781565'
'00778404'
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.ean8(prefixes=('45', '49'))
...
'49048766'
'45593826'
'45489242'
'45781568'
'49778403'
localized_ean(length=13)

Generate a localized EAN barcode of the specified length.

The value of length can only be 8 or 13 (default) which will create an EAN-8 or an EAN-13 barcode respectively.

This method uses ean() under the hood with the prefixes argument explicitly set to self.local_prefixes.

Examples:
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.localized_ean()
...
'0704876475930'
'0619489241158'
'1165938778403'
'1216097535137'
'0728711587145'
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.localized_ean(length=13)
...
'0704876475930'
'0619489241158'
'1165938778403'
'1216097535137'
'0728711587145'
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.localized_ean(length=8)
...
'12048762'
'03593820'
'01489248'
'04781561'
'11778400'
localized_ean13()

Generate a localized EAN-13 barcode.

This method uses localized_ean() under the hood with the length argument explicitly set to 13.

Examples:
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.localized_ean13()
...
'0704876475930'
'0619489241158'
'1165938778403'
'1216097535137'
'0728711587145'
localized_ean8()

Generate a localized EAN-8 barcode.

This method uses localized_ean() under the hood with the length argument explicitly set to 8.

Examples:
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.localized_ean8()
...
'12048762'
'03593820'
'01489248'
'04781561'
'11778400'