Generator

Faker allows you to create data collections with all the available functions of the library, this function is called generator. The generator function receives a tuple of functions called items and the name of a function called separator, which will be in charge of joining the result of the execution of the functions and adding a character between them.

Faker.generator(
	items=(
		Faker.user_name()
		,Faker.first_name()
		,Faker.city()
		,Faker.postcode()
		,string(Faker.user_name(),"@",Faker.domain_name())
	)
	, separator=Faker.string
)
=> Cira.BalistreriSadieThielbury00743Johnson.Marci@mas.name
Faker.generator(
	items=(
		Faker.user_name()
		,Faker.first_name()
		,Faker.city()
		,Faker.postcode()
		,string(Faker.user_name(),"@",Faker.domain_name())
	)
	, separator=Faker.stringWithSpaces
)
=> SKris Leota New Joe 35420-2738 UPadberg@ngac.com

Separator custom

It is possible to create a custom function that defines our own separator character.

Last updated

Was this helpful?