If you're looking to get the same result the way to do it is to seed the instance instead of modifying the global seed. Ie
In [2]: fake1 = faker.Faker()
In [3]: fake1.seed_instance(0)
In [4]: fake2 = faker.Faker()
In [5]: fake2.seed_instance(0)
In [6]: fake1.name()
Out[6]: u'Norma Fisher'
In [7]: fake2.name()
Out[7]: u'Norma Fisher'
Answer from Jonathan on Stack OverflowFaker
faker.readthedocs.io › en › master › fakerclass.html
Using the Faker Class — Faker 40.13.0 documentation
from faker import Faker fake = Faker() Faker.seed(0)
Faker
faker.readthedocs.io › en › master › providers › faker.providers.python.html
faker.providers.python — Faker 40.13.0 documentation
>>> Faker.seed(0) >>> for _ in range(5): ... fake.pyfloat() ... -6.36438676418356 -424604.985946604 -61.8878635605209 -829528891695.97 -69804.3874773259 · pyint(min_value: int = 0, max_value: int = 9999, step: int = 1) → int¶ · Examples: >>> Faker.seed(0) >>> for _ in range(5): ...
Videos
Faker
faker.readthedocs.io › en › master › providers › faker.providers.person.html
faker.providers.person — Faker 40.13.0 documentation
>>> Faker.seed(0) >>> for _ in range(5): ... fake.first_name_male() ... 'Ryan' 'Peter' 'Jason' 'David' 'Jorge' first_name_nonbinary() → str¶ · Examples: >>> Faker.seed(0) >>> for _ in range(5): ... fake.first_name_nonbinary() ... 'Megan' 'Katherine' 'Robert' 'Jonathan' 'William' language_name() → str¶ ·
PyPI
pypi.org › project › Faker
Faker · PyPI
If you are using pytest, you can seed the faker fixture by defining a faker_seed fixture. Please check out the pytest fixture docs to learn more. Run tests: $ tox · Write documentation for the providers of the default locale: $ python -m faker ...
» pip install Faker
Top answer 1 of 2
11
If you're looking to get the same result the way to do it is to seed the instance instead of modifying the global seed. Ie
In [2]: fake1 = faker.Faker()
In [3]: fake1.seed_instance(0)
In [4]: fake2 = faker.Faker()
In [5]: fake2.seed_instance(0)
In [6]: fake1.name()
Out[6]: u'Norma Fisher'
In [7]: fake2.name()
Out[7]: u'Norma Fisher'
2 of 2
5
As far as I make it, the faker seeds the global seed. This is fine, but it means that the second faker is pulling a global random number, so it is the same as if you were asking a second name to the first faker.
Faker
faker.readthedocs.io › en › master › providers › faker.providers.misc.html
faker.providers.misc — Faker 40.11.1 documentation
>>> Faker.seed(0) >>> for _ in range(5): ... fake.json(data_columns={'Spec':'@1.0.1', 'ID':'pyint', 'Details':{'Name':'name', 'Address':'address'}}, num_rows=2) ... '[{"Spec": "1.0.1", "ID": 6311, "Details": {"Name": "Jennifer Green", "Address": "7593 Juan Throughway Apt.
Stringfest Analytics
stringfestanalytics.com › home › blog › python in excel: how to generate fake data with faker
Python in Excel: How to generate fake data with Faker - Stringfest Analytics
August 17, 2024 - In the example below, my 10 names will remain the same after setting the random seed, but the one generated before setting the seed will continue to change. I usually set my random seed to 1234, but you can choose any integer—just be consistent. Awesome work so far! Now, let’s get a bit more sophisticated. Faker can generate much more than just names.
GitHub
github.com › xfxf › faker-python
GitHub - xfxf/faker-python: Faker is a Python package that generates fake data for you. · GitHub
Calling the same script twice with the same seed produces the same results. from faker import Faker fake = Faker() fake.seed(4321) print fake.name() > Margaret Boehm
Author xfxf
GitHub
github.com › firefoxxy8 › faker-1
GitHub - firefoxxy8/faker-1: Faker is a Python package that generates fake data for you.
Each generator can also be switched to its own instance of random.Random, separate to the shared one, by using the seed_instance() method, which acts the same way. For example: from faker import Faker fake = Faker() fake.seed_instance(4321) print(fake.name()) > Margaret Boehm
Author firefoxxy8
Faker
faker.readthedocs.io › en › master › providers › baseprovider.html
faker.providers — Faker 40.13.0 documentation
>>> Faker.seed(0) >>> for _ in range(5): ... fake.random_number(digits=3) ... 864 394 776 911 430 · >>> Faker.seed(0) >>> for _ in range(5): ... fake.random_number(digits=3, fix_len=False) ...
Faker
faker.readthedocs.io › en › master › providers › faker.providers.file.html
faker.providers.file — Faker 40.11.0 documentation
>>> Faker.seed(0) >>> for _ in range(5): ... fake.file_name(extension='') ...
GitHub
github.com › joke2k › faker › issues › 14
Enhance random generator repeatibility · Issue #14 · joke2k/faker
January 22, 2014 - import random from faker import Faker fake = Faker() # initial run fake.seed(1234) print fake.name() print fake.name() print fake.name() # repeated run with same data fake.seed(1234) print fake.name() print fake.name() print fake.name() # adding new fake calls prevent us from getting the same names we had originally fake.seed(1234) print fake.name(), fake.email() print fake.name(), fake.email() print fake.name(), fake.email() # One way is to implement a preserve/restore mechanism so that the user can get back to the previous trail of data fake.seed(1234) print fake.name() r = random.getstate()
Author deinspanjer
Blue Book
lyz-code.github.io › blue-book › coding › python › faker
Faker - The Blue Book
from random import SystemRandom @pytest.fixture(scope="session", autouse=True) def faker_seed() -> int: """Create a random seed for the Faker library.""" return SystemRandom().randint(0, 999999)