Mimesis: Personal.identifier returns the same value

Created on 9 Nov 2017  路  4Comments  路  Source: lk-geimfari/mimesis

The following code:

from mimesis import Personal


person = Personal('en')

for _ in range(10):
    print(person.identifier(mask='##-@@@-####'))

always prints the same identifiers. Sample output:

28-TKX-4789
28-TKX-4789
28-TKX-4789
28-TKX-4789
28-TKX-4789
28-TKX-4789
28-TKX-4789
28-TKX-4789
28-TKX-4789
28-TKX-4789

Whereas using Code.custom_code works fine:

from mimesis import Code


code = Code('en')

for _ in range(10):
    print(code.custom_code(mask='##-@@@-####'))

Sample output:

842-RSM-5674
414-HKU-3804
580-DHM-0816
822-IWU-2176
467-NWU-5089
535-KVB-3492
319-VMF-7333
665-YEZ-4076
915-ZXQ-5384
861-BOB-4256

I think this is because Personal.identifier(...) returns Code(self.locale).custom_code(...), each time creating a new temporary Code object, rather than storing a Code object in it, code = Code(self.locale), and calling code.custom_code(...) for it.

bug

All 4 comments

I'll further test and send a PR if the problem is what I suspect it to be.

@faheel Seems like you're right. I'll wait for your PR. Thanks!

@faheel I think that we need to move custom_code() to utils.py as function, becuase it is use too often. And the creation of the Code() objects each time is inexpedient.

@faheel So, i have fixed this issue in branch type-hinting.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lk-geimfari picture lk-geimfari  路  3Comments

pimuzzo picture pimuzzo  路  3Comments

lk-geimfari picture lk-geimfari  路  4Comments

lk-geimfari picture lk-geimfari  路  6Comments

jjgriff93 picture jjgriff93  路  5Comments