Skip to main content

Package to generate random facts

Project description

PyPI AUR version Downloads PyPI license Maintenance GitHub Issues GitHub Workflow Status GitHub followers GitHub Repo stars
Kofi Badge

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

  1. Make sure uv is properly installed
  2. Fork and clone the repository with git clone git@github.com:your-username/randfacts.git
  3. Install dependencies with uv sync --dev
  4. 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

randfacts-0.24.3.tar.gz (269.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

randfacts-0.24.3-py3-none-any.whl (271.2 kB view details)

Uploaded Python 3

File details

Details for the file randfacts-0.24.3.tar.gz.

File metadata

  • Download URL: randfacts-0.24.3.tar.gz
  • Upload date:
  • Size: 269.2 kB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for randfacts-0.24.3.tar.gz
Algorithm Hash digest
SHA256 5cd092faaa2c11d67315160b4b20bb859e24dc9153bd37ff59ae9e8569131bcd
MD5 8b185dc1b7ead0410b0f3f4dfa89ac40
BLAKE2b-256 42e0d307285876960cdcb29c1e0cd86a0d1e30603eaab09ab06f730512bdc371

See more details on using hashes here.

File details

Details for the file randfacts-0.24.3-py3-none-any.whl.

File metadata

  • Download URL: randfacts-0.24.3-py3-none-any.whl
  • Upload date:
  • Size: 271.2 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for randfacts-0.24.3-py3-none-any.whl
Algorithm Hash digest
SHA256 43b56a68d5251996392cf821bfa9d839fc7193ad571a28cf15ee2a672dcc5116
MD5 971e01e9e801557143385933df74651b
BLAKE2b-256 0a8c4989a8bb48ec62c85c2798e3dd6ce272a24d5b4a0ad9397687d87db45485

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page