For Tom Hanlon's email [colug-432] Python inline help or library exploration tips
and a reply [colug-432] Python inline help or library exploration tips.
In [1]:
# !pip install fake-factory ;# not pip install faker
In [2]:
from faker import Factory
import csv
import sys
In [3]:
def foo(filename, n):
with open(filename, 'w') as f:
for _ in range(n):
fake = Factory.create()
name = fake.profile()['name']
address_raw = fake.profile()['address']
address = address_raw.replace('\n', ', ')
birthdate = fake.profile()['birthdate']
phone = fake.phone_number()
writer = csv.writer(f)
writer.writerow((name, address, birthdate, phone))
In [4]:
filename = 'data.csv'
n = 3
foo(filename, n)
print(open(filename).read())
In [5]:
help(Factory)
In [6]:
import faker
help(faker)
In [7]:
help(faker.factory)
In [8]:
help(Factory.create().profile)
# There is a docstring, but it is incomplete.
In [9]:
print(Factory.create().profile.__doc__)
In [10]:
fake = Factory.create().profile()
In [11]:
help(fake)
In [12]:
fake.keys()
Out[12]:
In [13]:
fake
Out[13]: