Recipes to generate random instances of various types, beyond the scope of random.
Python's random implements generators for pseudo-random bytes, integers, and sequences. In random-recipes we collect additional functions to generate random instances of common object types, collection types, and file types that may be useful.
| Object Type | Function |
|---|---|
| bool | random_bool |
| bytes | random_bytes |
| decimal.Decimal | random_decimal |
| datetime.date | random_date |
| datetime.datetime | random_datetime |
| float | random_float |
| fractions.Fraction | random_fraction |
| int | random_int |
| str | random_str |
| Collection Type | Function |
|---|---|
| dict | random_dict |
| collections.abc.Iterable[dict] | random_dicts |
| File Extension | Function |
|---|---|
| .csv | random_csv |
Install the library with pip from PyPi:
pip install random-recipes