Basic usageΒΆ

The purpose of the loremipsum package is to provide high level API to a loremipsum.generator.Generator that returns random plausible text based on a sample. There are 2 sets of functions:

  • Those with get_ prefixed functions that return the desired text
  • Those with generate_ prefixed functions that also return additional informations like the number of words or sentences used.

So, on the average, you probably want to use the get_ prefixed functions and just get the text:

>>> sentences_list = list(loremipsum.get_sentences(5))
>>> len(sentences_list)
5
>>>

Otherwise, if you fancy some info on the generated text, you want to use the generate_ prefixed functions:

>>> sentences_count, words_count, paragraph = loremipsum.generate_paragraph()
>>> sentences_count
11
>>> words_count
109
>>> len(paragraph)
695

The above mentioned functions will generate text using the default sample, which is a pseudo latin text known as Lorem Ipsum. The loremipsum.samples pluggable sub-package expose simple functions to browse, get any or set default plugged samples. Setting a different default sample will, of course, affect the text generated by the functions in this package. loremipsum.generator, instead, exposes a lower level API to help you to create, load, dump and use your own samples and text generators.