faker.providers.lorem

class faker.providers.lorem.Provider(generator: Any)

Bases: BaseProvider

Implement default lorem provider for Faker.

Important

The default locale of the lorem provider is la. When using a locale without a localized lorem provider, the la lorem provider will be used, so generated words will be in pseudo-Latin. The locale used for the standard provider docs was en_US, and en_US has a localized lorem provider which is why the samples here show words in American English.

paragraph(nb_sentences: int = 3, variable_nb_sentences: bool = True, ext_word_list: Sequence[str] | None = None) str

Generate a paragraph.

The nb_sentences argument controls how many sentences the paragraph will contain, and setting variable_nb_sentences to False will generate the exact amount, while setting it to True (default) will generate a random amount (+/-40%, minimum of 1) using randomize_nb_elements().

Under the hood, sentences() is used to generate the sentences, so the argument ext_word_list works in the same way here as it would in that method.

Examples:

>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.paragraph(nb_sentences=5)
...
'American whole magazine truth stop whose. On traditional measure example sense peace. Would mouth relate own chair. Role together range line. Government first policy daughter.'
'Kind miss artist truth trouble behavior style. Ability management test during foot that course nothing. Sound central myself before year. Your majority feeling fact by four two. White owner onto knowledge other. First drug contain start almost wonder.'
'Attorney quickly candidate change although bag record. Raise study modern miss dog Democrat quickly. Often late produce you true soldier. Food break onto friend.'
'Administration even relate head color. Staff beyond chair recently and off. Own available buy country store build before. Already against which continue.'
'Decision song view age international big employee. Author feeling job article level. Beyond write current grow rule stuff truth college.'
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.paragraph(nb_sentences=5, variable_nb_sentences=False)
...
'Serious inside else memory if six. Whose group through despite cause. Sense peace economy travel. Total financial role together range line beyond its. Policy daughter need kind miss artist truth trouble.'
'Rest human station property. Partner stock four. Region as true develop sound central. Language ball floor meet usually board necessary. Natural sport music white.'
'Natural explain before something first drug contain start. Party prevent live. Quickly candidate change although. Together type music hospital. Every speech support time operation wear often.'
'Manage political record word group food break. Picture suddenly drug rule bring determine some forward. Beyond chair recently and. Plant view own available buy country store. Hospital have wonder already.'
'Create wife responsibility. Decision song view age international big employee. Author feeling job article level. Beyond write current grow rule stuff truth college. Whom around put suddenly garden.'
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.paragraph(nb_sentences=5, ext_word_list=['abc', 'def', 'ghi', 'jkl'])
...
'Abc jkl def jkl jkl jkl. Ghi jkl ghi def jkl ghi. Jkl ghi ghi ghi abc. Ghi jkl ghi def. Def def ghi abc.'
'Def ghi abc jkl jkl abc jkl. Abc def jkl abc def jkl abc ghi. Jkl abc ghi abc jkl. Jkl def def def abc def jkl. Jkl ghi ghi def ghi. Def abc abc jkl abc jkl.'
'Abc ghi abc abc abc abc ghi. Ghi jkl ghi ghi abc abc ghi. Ghi def ghi jkl jkl jkl. Def abc ghi def.'
'Abc def ghi def abc. Jkl abc abc ghi abc ghi. Ghi abc abc abc jkl abc abc. Abc abc jkl abc.'
'Abc jkl jkl abc def abc def. Abc def def abc def. Abc jkl abc def ghi jkl jkl abc.'
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.paragraph(nb_sentences=5, variable_nb_sentences=False, ext_word_list=['abc', 'def', 'ghi', 'jkl'])
...
'Jkl def def ghi def jkl. Jkl def jkl abc abc. Jkl ghi def jkl. Jkl def ghi jkl ghi def abc def. Ghi abc ghi def ghi abc jkl jkl.'
'Ghi def jkl ghi. Ghi jkl def. Ghi abc jkl abc jkl abc. Def abc def ghi jkl abc ghi. Ghi jkl ghi jkl.'
'Ghi def abc jkl def abc abc jkl. Ghi ghi def. Ghi abc abc abc. Jkl jkl ghi def. Def jkl jkl jkl ghi jkl ghi.'
'Def ghi ghi jkl def def abc. Ghi jkl abc ghi abc abc jkl def. Abc abc ghi abc. Ghi jkl ghi abc abc abc jkl. Def def jkl abc.'
'Abc jkl ghi. Abc jkl jkl abc def abc def. Abc def def abc def. Abc jkl abc def ghi jkl jkl abc. Jkl abc ghi jkl def.'
paragraphs(nb: int = 3, ext_word_list: Sequence[str] | None = None) List[str]

Generate a list of paragraphs.

This method uses paragraph() under the hood to generate paragraphs, and the nb argument controls exactly how many sentences the list will contain. The ext_word_list argument works in exactly the same way as well.

Examples:

>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.paragraphs(nb=5)
...
['American whole magazine truth stop whose. On traditional measure example sense peace. Would mouth relate own chair.', 'Together range line beyond. First policy daughter need kind miss.', 'Trouble behavior style report size personal partner. During foot that course nothing draw.', 'Language ball floor meet usually board necessary. Natural sport music white.', 'Onto knowledge other his offer face country. Almost wonder employee attorney. Theory type successful together. Raise study modern miss dog Democrat quickly.']
['Every manage political record word group food break. Picture suddenly drug rule bring determine some forward. Beyond chair recently and.', 'Own available buy country store build before. Already against which continue. Look road article quickly.', 'Per structure attorney author feeling job. Mean always beyond write. Employee toward like total now.', 'Small citizen class morning. Others kind company likely.', 'Themselves true power home price check real. Score from animal exactly drive well good. Pull opportunity throughout take car.']
['Security stock ball organization recognize civil. Pm her then nothing increase.', 'Industry product another knowledge else citizen month. Traditional page a although for study anyone. Could yourself plan base rise would.', 'First degree response able state more. Couple part cup few. Beyond take however ball.', 'Son break either president stage population boy. Everything affect American race.', 'Water voice travel among see red. Republican total policy head Mrs debate onto. Catch even front.']
['Full per among clearly. Face house nature fall long dream answer conference. Rock few structure federal board night loss.', 'Buy break marriage also friend reach. Turn phone heart window. Assume be seek article.', 'Hour million large major.', 'Institution happy write end since. Court boy state table agree moment. Budget huge debate among way. Perhaps bit learn gun still.', 'Work chance image quite there many true follow. Your play themselves myself use act relationship.']
['Along chance either six success on. At be than always different American address. Former claim chance prevent why measure too.', 'Off question source. Wrong section town deal movement out stay lot. Parent do ten after those scientist.', 'Now four management energy stay significant his. Artist political camera expert stop area.', 'Individual man tell response purpose character would.', 'Partner hit another. Sing after our car food record power. Himself simply make thing particular.']
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.paragraphs(nb=5, ext_word_list=['abc', 'def', 'ghi', 'jkl'])
...
['Abc jkl def jkl jkl jkl. Ghi jkl ghi def jkl ghi. Jkl ghi ghi ghi abc.', 'Jkl ghi def abc. Def ghi abc ghi def ghi.', 'Jkl abc jkl ghi jkl ghi ghi. Abc def jkl abc ghi abc.', 'Def abc def ghi jkl abc ghi. Ghi jkl ghi jkl.', 'Ghi def ghi def ghi def abc. Abc jkl def abc. Jkl jkl jkl jkl. Ghi jkl ghi ghi abc abc ghi.']
['Def def ghi ghi jkl def def abc. Ghi jkl abc ghi abc abc jkl def. Abc abc ghi abc.', 'Ghi abc abc abc jkl abc abc. Abc abc jkl abc. Def ghi abc ghi.', 'Ghi jkl abc abc def def. Ghi abc abc jkl. Def jkl def jkl ghi.', 'Jkl abc abc ghi. Ghi def abc def.', 'Jkl jkl ghi def ghi abc ghi. Ghi def abc def abc jkl def. Ghi ghi jkl jkl abc.']
['Ghi jkl abc ghi ghi abc. Ghi def jkl ghi def.', 'Def ghi abc def def abc ghi. Jkl ghi abc abc def jkl abc. Abc jkl ghi abc ghi jkl.', 'Def abc ghi abc jkl ghi. Abc ghi abc def. Abc jkl def abc.', 'Jkl abc def ghi jkl ghi abc. Def abc abc ghi.', 'Jkl jkl jkl abc ghi ghi. Ghi jkl ghi def ghi abc ghi. Abc def def.']
['Def ghi abc abc. Def def ghi def def abc abc abc. Ghi def jkl def abc ghi def.', 'Abc abc def abc def ghi. Jkl ghi def jkl. Abc abc ghi abc.', 'Def ghi def def.', 'Def def jkl def jkl. Abc abc jkl jkl abc ghi. Abc def abc abc jkl. Ghi abc def def jkl.', 'Jkl abc def ghi jkl def jkl def. Jkl ghi jkl ghi jkl abc ghi.']
['Abc abc def jkl jkl ghi. Abc abc jkl abc abc abc abc. Def abc abc ghi jkl ghi jkl.', 'Ghi ghi jkl. Jkl ghi jkl abc ghi ghi jkl def. Ghi abc jkl abc jkl ghi.', 'Ghi def def def jkl jkl def. Abc ghi abc def jkl abc.', 'Def def jkl ghi ghi abc jkl.', 'Ghi def abc. Jkl abc ghi abc def ghi ghi. Def jkl def jkl ghi.']
sentence(nb_words: int = 6, variable_nb_words: bool = True, ext_word_list: Sequence[str] | None = None) str

Generate a sentence.

The nb_words argument controls how many words the sentence will contain, and setting variable_nb_words to False will generate the exact amount, while setting it to True (default) will generate a random amount (+/-40%, minimum of 1) using randomize_nb_elements().

Under the hood, words() is used to generate the words, so the argument ext_word_list works in the same way here as it would in that method.

Examples:

>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.sentence(nb_words=10)
...
'Serious inside else memory if six field live on traditional.'
'Cause cause believe son would mouth relate own chair better available sure.'
'Line beyond its particularly tree whom local tend employee source.'
'Trouble behavior style report size personal partner stock four room region as true.'
'Draw whose sort language ball floor meet usually.'
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.sentence(nb_words=10, variable_nb_words=False)
...
'Such serious inside else memory if six field live on.'
'Traditional measure example sense peace economy travel work special total.'
'Financial role together range line beyond its particularly tree whom.'
'Local tend employee source nature add rest human station property.'
'Ability management test during foot that course nothing draw whose.'
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.sentence(nb_words=10, ext_word_list=['abc', 'def', 'ghi', 'jkl'])
...
'Jkl def def ghi def jkl def def ghi jkl.'
'Abc abc abc jkl jkl ghi ghi ghi abc abc abc jkl.'
'Def abc def ghi jkl jkl def jkl def jkl.'
'Jkl abc jkl ghi jkl ghi ghi jkl def ghi ghi abc jkl.'
'Abc jkl jkl def abc def ghi jkl.'
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.sentence(nb_words=10, variable_nb_words=True, ext_word_list=['abc', 'def', 'ghi', 'jkl'])
...
'Jkl def def ghi def jkl def def ghi jkl.'
'Abc abc abc jkl jkl ghi ghi ghi abc abc abc jkl.'
'Def abc def ghi jkl jkl def jkl def jkl.'
'Jkl abc jkl ghi jkl ghi ghi jkl def ghi ghi abc jkl.'
'Abc jkl jkl def abc def ghi jkl.'
sentences(nb: int = 3, ext_word_list: Sequence[str] | None = None) List[str]

Generate a list of sentences.

This method uses sentence() under the hood to generate sentences, and the nb argument controls exactly how many sentences the list will contain. The ext_word_list argument works in exactly the same way as well.

Examples:

>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.sentences()
...
['Serious inside else memory if six.', 'Whose group through despite cause.', 'Sense peace economy travel.']
['Total financial role together range line beyond its.', 'Policy daughter need kind miss artist truth trouble.', 'Rest human station property.']
['Partner stock four.', 'Region as true develop sound central.', 'Language ball floor meet usually board necessary.']
['Natural sport music white.', 'Natural explain before something first drug contain start.', 'Party prevent live.']
['Quickly candidate change although.', 'Together type music hospital.', 'Every speech support time operation wear often.']
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.sentences(nb=5)
...
['Serious inside else memory if six.', 'Whose group through despite cause.', 'Sense peace economy travel.', 'Total financial role together range line beyond its.', 'Policy daughter need kind miss artist truth trouble.']
['Rest human station property.', 'Partner stock four.', 'Region as true develop sound central.', 'Language ball floor meet usually board necessary.', 'Natural sport music white.']
['Natural explain before something first drug contain start.', 'Party prevent live.', 'Quickly candidate change although.', 'Together type music hospital.', 'Every speech support time operation wear often.']
['Manage political record word group food break.', 'Picture suddenly drug rule bring determine some forward.', 'Beyond chair recently and.', 'Plant view own available buy country store.', 'Hospital have wonder already.']
['Create wife responsibility.', 'Decision song view age international big employee.', 'Author feeling job article level.', 'Beyond write current grow rule stuff truth college.', 'Whom around put suddenly garden.']
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.sentences(nb=5, ext_word_list=['abc', 'def', 'ghi', 'jkl'])
...
['Jkl def def ghi def jkl.', 'Jkl def jkl abc abc.', 'Jkl ghi def jkl.', 'Jkl def ghi jkl ghi def abc def.', 'Ghi abc ghi def ghi abc jkl jkl.']
['Ghi def jkl ghi.', 'Ghi jkl def.', 'Ghi abc jkl abc jkl abc.', 'Def abc def ghi jkl abc ghi.', 'Ghi jkl ghi jkl.']
['Ghi def abc jkl def abc abc jkl.', 'Ghi ghi def.', 'Ghi abc abc abc.', 'Jkl jkl ghi def.', 'Def jkl jkl jkl ghi jkl ghi.']
['Def ghi ghi jkl def def abc.', 'Ghi jkl abc ghi abc abc jkl def.', 'Abc abc ghi abc.', 'Ghi jkl ghi abc abc abc jkl.', 'Def def jkl abc.']
['Abc jkl ghi.', 'Abc jkl jkl abc def abc def.', 'Abc def def abc def.', 'Abc jkl abc def ghi jkl jkl abc.', 'Jkl abc ghi jkl def.']
text(max_nb_chars: int = 200, ext_word_list: Sequence[str] | None = None) str

Generate a text string.

The max_nb_chars argument controls the approximate number of characters the text string will have, and depending on its value, this method may use either words(), sentences(), or paragraphs() for text generation. The ext_word_list argument works in exactly the same way it would in any of those methods.

Examples:

>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.text(max_nb_chars=20)
...
'Three image son.'
'Kitchen amount.'
'Much mention.'
'Why step themselves.'
'Me help past wait.'
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.text(max_nb_chars=80)
...
'Serious inside else memory if six. Whose group through despite cause.'
'Total financial role together range line beyond its.'
'Rest human station property. Partner stock four.'
'Language ball floor meet usually board necessary. Natural sport music white.'
'Party prevent live. Quickly candidate change although.'
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.text(max_nb_chars=160)
...
'American whole magazine truth stop whose. On traditional measure example sense peace. Would mouth relate own chair.'
'Trouble behavior style report size personal partner. During foot that course nothing draw.'
'Onto knowledge other his offer face country. Almost wonder employee attorney. Theory type successful together. Raise study modern miss dog Democrat quickly.'
'Own available buy country store build before. Already against which continue. Look road article quickly.'
'Small citizen class morning. Others kind company likely.'
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.text(ext_word_list=['abc', 'def', 'ghi', 'jkl'])
...
'Abc jkl def jkl jkl jkl. Ghi jkl ghi def jkl ghi. Jkl ghi ghi ghi abc.\nJkl ghi def abc. Def ghi abc ghi def ghi.\nJkl abc jkl ghi jkl ghi ghi. Abc def jkl abc ghi abc.'
'Ghi def ghi def ghi def abc. Abc jkl def abc. Jkl jkl jkl jkl. Ghi jkl ghi ghi abc abc ghi.\nDef def ghi ghi jkl def def abc. Ghi jkl abc ghi abc abc jkl def. Abc abc ghi abc.'
'Ghi jkl abc abc def def. Ghi abc abc jkl. Def jkl def jkl ghi.\nJkl abc abc ghi. Ghi def abc def.\nJkl jkl ghi def ghi abc ghi. Ghi def abc def abc jkl def. Ghi ghi jkl jkl abc.'
'Def ghi abc def def abc ghi. Jkl ghi abc abc def jkl abc. Abc jkl ghi abc ghi jkl.\nDef abc ghi abc jkl ghi. Abc ghi abc def. Abc jkl def abc.\nJkl abc def ghi jkl ghi abc. Def abc abc ghi.'
'Def ghi abc abc. Def def ghi def def abc abc abc. Ghi def jkl def abc ghi def.\nAbc abc def abc def ghi. Jkl ghi def jkl. Abc abc ghi abc.\nDef ghi def def.'
texts(nb_texts: int = 3, max_nb_chars: int = 200, ext_word_list: Sequence[str] | None = None) List[str]

Generate a list of text strings.

The nb_texts argument controls how many text strings the list will contain, and this method uses text() under the hood for text generation, so the two remaining arguments, max_nb_chars and ext_word_list will work in exactly the same way as well.

Examples:

>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.texts(nb_texts=5)
...
['American whole magazine truth stop whose. On traditional measure example sense peace. Would mouth relate own chair.\nTogether range line beyond. First policy daughter need kind miss.', 'Language ball floor meet usually board necessary. Natural sport music white.', 'Every manage political record word group food break. Picture suddenly drug rule bring determine some forward. Beyond chair recently and.', 'Per structure attorney author feeling job. Mean always beyond write. Employee toward like total now.\nSmall citizen class morning. Others kind company likely.', 'Security stock ball organization recognize civil. Pm her then nothing increase.']
['First degree response able state more. Couple part cup few. Beyond take however ball.\nSon break either president stage population boy. Everything affect American race.', 'Full per among clearly. Face house nature fall long dream answer conference. Rock few structure federal board night loss.', 'Hour million large major.\nInstitution happy write end since. Court boy state table agree moment. Budget huge debate among way. Perhaps bit learn gun still.', 'Along chance either six success on. At be than always different American address. Former claim chance prevent why measure too.', 'Now four management energy stay significant his. Artist political camera expert stop area.\nIndividual man tell response purpose character would.']
['Place full buy radio perform small camera treatment. True their race special million. Although hot he couple ground.', 'Between similar safe air. Issue indicate market ten foot education good. Grow ahead girl act.\nAudience throw debate daughter purpose voice. Security fall ready usually.', 'Player contain year bill ok choose today. Source firm drug senior.\nInformation animal car after back available. Federal indicate unit opportunity fear great.', 'Painting child reflect up control instead company. Future model green place beat sense far.', 'Three report know second government the pull. Other along society figure future. Teacher three seven attention team executive care.']
['Feel seat appear perform agent likely. Suffer without rather.\nAccording American per yourself their record. Cell of course its respond.', 'Almost plan that hair sea quality.\nFather beautiful than seem sign third in approach. Program possible natural same issue lawyer effort.', 'Eight miss couple bag thank generation. Economy rock feeling might his. Gas Republican and various authority leave right.\nWithout leave brother bank better she.', 'Represent since method left plant. Discussion budget situation between run. Design they young according movement.', 'Happen play speech theory choice computer. Career deal trip market. Dog car do his part.\nMaterial truth pattern ago other majority final when. Present produce manager well lose finish summer.']
['General class admit of around. Character against physical agency and difficult president at.\nWill institution throughout describe itself group. Power road size impact.', 'Important hope about catch. Style record bag down stock computer watch. Sea stuff no response.', 'Significant now energy. Lay return identify. Anything event yet effect quite reflect upon.\nMight history strong economy break word source. Only result race government trouble.', 'Notice kind game act.\nSection could nature interest wear. Morning as police often. Place myself his itself find add sing.\nMrs never wrong couple site. Suddenly seek choice produce.', 'Of door research tell. When clearly type up. Wait education think similar particular before.\nAction economy several hit simple personal home.\nLet stop camera report foreign agency list miss.']
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.texts(nb_texts=5, max_nb_chars=50)
...
['Serious inside else memory if six.', 'Sense peace economy travel.', 'Rest human station property. Partner stock four.', 'Language ball floor meet usually board necessary.', 'Party prevent live.']
['Together type music hospital.', 'Manage political record word group food break.', 'Beyond chair recently and.', 'Hospital have wonder already.', 'Author feeling job article level.']
['Whom around put suddenly garden.', 'Themselves true power home price check real.', 'Pull opportunity throughout take car.', 'I reduce industry. Close ask reduce.', 'Anyone state wind indeed nature white without.']
['Add senior woman put partner.', 'Little type physical against.', 'Everything affect American race.', 'Republican total policy head Mrs debate onto.', 'Responsibility full per among clearly word.']
['Film tax rock.', 'Front something speech buy break marriage also.', 'Assume be seek article. Better news face.', 'Issue grow ask tell. Total later quality.', 'Perhaps bit learn gun still.']
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.texts(nb_texts=5, max_nb_chars=50, ext_word_list=['abc', 'def', 'ghi', 'jkl'])
...
['Jkl def def ghi def jkl. Jkl def jkl abc abc.', 'Jkl def ghi jkl ghi def abc def.', 'Ghi def jkl ghi. Ghi jkl def.', 'Def abc def ghi jkl abc ghi. Ghi jkl ghi jkl.', 'Ghi ghi def. Ghi abc abc abc. Jkl jkl ghi def.']
['Def ghi ghi jkl def def abc.', 'Abc abc ghi abc. Ghi jkl ghi abc abc abc jkl.', 'Abc jkl ghi. Abc jkl jkl abc def abc def.', 'Abc jkl abc def ghi jkl jkl abc.', 'Abc jkl ghi abc ghi. Jkl jkl ghi def ghi abc ghi.']
['Ghi ghi jkl jkl abc. Def def ghi abc abc.', 'Def ghi def. Abc abc ghi.', 'Abc jkl jkl def ghi jkl jkl. Jkl def ghi def.', 'Abc ghi jkl def jkl. Def jkl ghi abc.', 'Def abc abc ghi. Def def ghi jkl jkl jkl ghi.']
['Abc def def. Ghi def ghi abc abc jkl.', 'Def jkl ghi. Def def def abc jkl.', 'Ghi jkl jkl ghi def jkl. Abc abc ghi abc.', 'Jkl ghi abc abc abc jkl ghi. Def def abc jkl.', 'Def def ghi jkl. Ghi abc def def jkl.']
['Jkl def jkl def def def. Ghi jkl abc ghi ghi.', 'Def ghi def jkl ghi jkl abc abc.', 'Jkl ghi jkl ghi ghi ghi jkl.', 'Ghi abc jkl abc jkl ghi. Ghi def abc jkl jkl.', 'Def jkl abc abc def. Jkl ghi abc ghi jkl def abc.']
word(part_of_speech: str | None = None, ext_word_list: Sequence[str] | None = None) str

Generate a word.

This method uses words() under the hood with the nb argument set to 1 to generate the result.

Examples:

>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.word()
...
'three'
'image'
'son'
'voice'
'kitchen'
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.word(ext_word_list=['abc', 'def', 'ghi', 'jkl'])
...
'jkl'
'jkl'
'abc'
'ghi'
'jkl'
words(nb: int = 3, part_of_speech: str | None = None, ext_word_list: Sequence[str] | None = None, unique: bool = False) List[str]

Generate a tuple of words.

The nb argument controls the number of words in the resulting list, and if ext_word_list is provided, words from that list will be used instead of those from the locale provider’s built-in word list.

If unique is True, this method will return a list containing unique words. Under the hood, random_sample() will be used for sampling without replacement. If unique is False, random_choices() is used instead, and the list returned may contain duplicates.

part_of_speech is a parameter that defines to what part of speech the returned word belongs. If ext_word_list is not None, then part_of_speech is ignored. If the value of part_of_speech does not correspond to an existent part of speech according to the set locale, then an exception is raised.

Warning

Depending on the length of a locale provider’s built-in word list or on the length of ext_word_list if provided, a large nb can exhaust said lists if unique is True, raising an exception.

Examples:

>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.words()
...
['such', 'serious', 'inside']
['else', 'memory', 'if']
['six', 'field', 'live']
['on', 'traditional', 'measure']
['example', 'sense', 'peace']
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.words(nb=5)
...
['such', 'serious', 'inside', 'else', 'memory']
['if', 'six', 'field', 'live', 'on']
['traditional', 'measure', 'example', 'sense', 'peace']
['economy', 'travel', 'work', 'special', 'total']
['financial', 'role', 'together', 'range', 'line']
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.words(nb=5, ext_word_list=['abc', 'def', 'ghi', 'jkl'])
...
['jkl', 'jkl', 'def', 'def', 'ghi']
['def', 'jkl', 'def', 'def', 'ghi']
['jkl', 'ghi', 'def', 'jkl', 'ghi']
['def', 'jkl', 'jkl', 'jkl', 'jkl']
['def', 'ghi', 'jkl', 'ghi', 'def']
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.words(nb=4, ext_word_list=['abc', 'def', 'ghi', 'jkl'], unique=True)
...
['jkl', 'def', 'abc', 'ghi']
['jkl', 'def', 'ghi', 'abc']
['ghi', 'jkl', 'abc', 'def']
['ghi', 'abc', 'jkl', 'def']
['def', 'jkl', 'abc', 'ghi']