Randfacts is a Python module that generates random facts. You can use randfacts.get_fact() to return a random fun fact. Disclaimer: Facts are not guaranteed to be true.
Installation
randfacts can either be installed via pip or via the AUR, whichever way you prefer.
Installation via uv/pipx/pip:
# Install with UV:
$ uv tool install randfacts
# Or just try it out:
$ uvx randfacts
# Install with pipx:
$ pipx install randfacts
# Install with bare pip:
$ pip3 install randfacts
Installation via AUR:
Via your AUR helper, like paru:
$ paru -S python-randfacts
Or manually
$ git clone https://aur.archlinux.org/python-randfacts.git && cd python-randfacts
$ makepkg -si
Usage and examples
import randfacts
x = randfacts.get_fact()
print(x)
The above example will print a random fact like:
Penguins can't taste sweet or savory flavors, only sour and salty ones
This package has a filter option to filter out potentially inappropriate facts. The filter is on by default. To disable the filter, you can just set the filter_enabled parameter to False.
from randfacts import get_fact
print(get_fact(False))
# or
print(get_fact(filter_enabled=False))
get_fact also has a parameter that will make the function only return unsafe facts. This argument takes precedence over the filter_enabled argument. For example:
print(get_fact(only_unsafe=True))
If you want to access the list of facts directly, you can just import the safe_facts, unsafe_facts, or all_facts lists from the randfacts module.
Command line usage
randfacts can be executed via the command line with the following commands:
Normal execution; only SFW (safe for work) facts
$ python3 -m randfacts
The unsafe argument can be supplied to provide only NSFW (not safe for work) facts
$ python3 -m randfacts --unsafe
The mixed argument can be provided to provide both SFW and NSFW facts.
$ python3 -m randfacts --mixed
More help.
$ python3 -m randfacts --help
Contributing
Contributions are welcome, this project uses uv to manage it's dependencies, so setup is very simple.
Development Setup
- Make sure uv is properly installed
- Fork and clone the repository with
git clone git@github.com:your-username/randfacts.git - Install dependencies with
uv sync --dev - After making changes, ensure the tests pass, and add any unit tests needed to bring code coverage to 100% with the following command:
# check everything, if you're just working on one particular issue,
# see the Makefile for more granular tasks
make check-all
Duplicate facts test
I've created a fairly complex duplicate fact detection test in Rust. It will be easier to run on your machine to check/fix any issues, but it also runs in CI if you don't want to set up Rust. It can be run with the following:
cd tests/checkduplicates
cargo run --release
Release files for randfacts 0.24.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| randfacts-0.24.4.tar.gz | 269.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| randfacts-0.24.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 540.1 kB
Release files / randfacts-0.24.4.tar.gz
| Download URL | randfacts-0.24.4.tar.gz |
|---|---|
| Size | 269.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
268124a72f21cf7e64bc2ed45d4876e2f0878e6bf87e4d9ad522ebae29064be3
|
|
BLAKE2b-256 checksum How to use checksums |
94a2f717134743fbedda2d66392b8a0bd9eefbb4369108158d92478b5b0734b5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / randfacts-0.24.4-py3-none-any.whl
| Download URL | randfacts-0.24.4-py3-none-any.whl |
|---|---|
| Size | 271.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
beb07c7b61352f86410aa178be0a3e6b031a454e9df90e5487fb10f7ad21ddbb
|
|
BLAKE2b-256 checksum How to use checksums |
008da87b495df3f175f138c00f1539e9a9f771dd430e18660b02ce1c50cf7b51
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|