Example module

This module is not part of the project. It is here to serve as a style example and the subject of example unit tests.

Tip

To remove this module, its unit tests and documentation from the project, use the “clear_examples.sh” script in the project’s root folder

Docstrings are based on this example

Unit tests for this module are in: ../tests/test_example.py

str_repeat(s, n=1)[source]

Example function that repeats a string a number of times

Parameters:
  • s (str) – string to repeat
  • n (int) – number of repetitions
Returns:

s repeated n times

Return type:

str

Raises:

Example

>>> str_repeat('a', 3)
'aaa'
>>> str_repeat('and_again_', 3)
'and_again_and_again_and_again_'
>>> str_repeat('x', -1)
Traceback (most recent call last):
...
ValueError: n negative