Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get random locale with python Faker lib

Tags:

python

faker

Not sure if this exist or not, is it possible to generate random locales with python Faker lib? (https://faker.readthedocs.io/).

Good to have: generate supported locales

like image 582
Thomas Decaux Avatar asked Nov 18 '25 22:11

Thomas Decaux


1 Answers

As a workaround:

>>> fake = Faker(["fr_FR", "it_IT", "de_DE"])
>>> fake.locales
['fr_FR', 'it_IT', 'de_DE']
>>> import random
>>> random.choices(fake.locales)[0]
de_DE
like image 122
Thomas Decaux Avatar answered Nov 20 '25 13:11

Thomas Decaux



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!