Mimesis: How i can create two telephones for one person?

Created on 21 Nov 2017  路  7Comments  路  Source: lk-geimfari/mimesis

from mimesis import Personal
a = Personal("en")
b = Personal("en")
assert a.telephone('+#-(###)-###-####') == b.telephone('+#-(###)-###-####')
bug question

Most helpful comment

Thanks.

All 7 comments

@4kpt You can't create two similar telephones when you create two instances. Theoretical it is possible, but the probability is very small.

You can use following format, which is much easier, because here no need create two instances of Personal:

>>> from mimesis import Personal
>>> per = Personal('en')
>>> a = b = per.telephone('+#-(###)-###-####')
>>> a == b
True

Or, maybe this decision does not suit for you? If not, why?

I need two different telephones like work phone and home phone. How can i get it?

@4kpt There are bug with generating telephone by mask which has been fixed in version 1.0.0. I'll publish new version in next week.

Try use this:

>>> from mimesis import Code
>>> code = Code()
>>> a = code.custom_code('+#-(###)-###-####')
>>> b = code.custom_code('+#-(###)-###-####')
>>> a
'+3-(289)-022-8253'
>>> b
'+3-(504)-942-9931'
>>> 

We have seriously improved the library in version 1.0.0 and these inconveniences should pay off by clearer API.

But i need use usa-specific phone number like Person("en").telephone...
Why create new Person instance return old person telephone?

@4kpt We have discussed why in #286. It's a bug related to code.Code.custom_code: details.

@4kpt If you are really really need usa-specific phone numbers, then you can use this workaround:

>>> import random

>>> from mimesis import Personal, Code
>>> code = Code()
>>> masks = Personal('en').data['telephone_fmt']
>>> a = code.custom_code(mask=random.choice(masks))

Thanks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pimuzzo picture pimuzzo  路  3Comments

kairichard picture kairichard  路  6Comments

lk-geimfari picture lk-geimfari  路  3Comments

lk-geimfari picture lk-geimfari  路  4Comments

lk-geimfari picture lk-geimfari  路  5Comments