Registry / communication / pyjokes

pyjokes

JSON →
library0.8.3pypypi✓ verified 87d ago

PyJokes is a Python library that provides one-liner jokes, primarily focusing on programmer humor. It also supports general and neutral joke categories, and multiple languages. Currently at version 0.8.3, it maintains a stable API with infrequent but consistent updates.

pip install pyjokes
INSTALL
IMPORT
SIG · PYJOKES
P
pyjokes
communicationpythonv0.8.3
Install
1.5s avg
Import
17ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.8.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.017s · 18MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 1.5s · import 0.016s · 19MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

get_joke
from pyjokes import get_joke
get_jokes
from pyjokes import get_jokes

This example demonstrates how to fetch a single joke by category and language using `pyjokes.get_joke()`. It also shows how to handle potential issues if a specific language/category combination is unavailable.

import pyjokes # Get a random programmer joke programmer_joke = pyjokes.get_joke(category='programmer') print("Programmer Joke:", programmer_joke) # Get a random neutral joke in German try: german_joke = pyjokes.get_joke(language='de', category='neutral') print("German Neutral Joke:", german_joke) except Exception as e: print(f"Could not fetch German joke (might not be available): {e}") # Get a list of all jokes (careful, can be long!) # all_jokes_list = pyjokes.get_jokes(category='all', language='en') # print(f"First 3 jokes from list: {all_jokes_list[:3]}")
Debug
Known issues
breakingThe `chuck` joke category, previously advertised or available in older versions/README, is no longer supported as of version 0.8.0+. Attempting to request jokes from this category will lead to a `KeyError` or unexpected behavior, as it has been removed from the core joke data.
fix
Use supported categories like 'programmer', 'neutral', or 'all'. You can inspect `pyjokes.CATEGORIES` for a definitive list of current options.
affects: >=0.8.0
gotchaUsing `pyjokes.get_joke()` with a non-existent or unsupported language/category combination might silently fall back to default English/all jokes instead of raising an error. This can lead to unexpected joke content if you expect specific localization or theme.
fix
Verify the returned joke's content, or explicitly check `pyjokes.LANGUAGES` and `pyjokes.CATEGORIES` for supported options before making a request to ensure you get the desired joke type.
affects: All versions
gotchaThe functions `pyjokes.get_joke()` and `pyjokes.get_jokes()` return different types: `get_joke()` returns a single string, while `get_jokes()` returns a list of strings. Confusing these can lead to `TypeError` when attempting string operations on a list or iterating over a string.
fix
Ensure you are using the correct function for your desired output. Use `get_joke()` for a single string, or `get_jokes()` if you intend to iterate over multiple jokes. Example: `for joke in pyjokes.get_jokes(): print(joke)`.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'pyjokes'
The `pyjokes` library has not been installed in the current Python environment.
fix
Install the package using pip: `pip install pyjokes`
KeyError: 'chuck'
An unsupported joke category was requested. The 'chuck' category was removed in recent versions, but may still appear in older documentation or examples.
fix
Use one of the currently supported categories: 'programmer', 'neutral', or 'all'. You can check `pyjokes.CATEGORIES` for a definitive list.
AttributeError: 'list' object has no attribute 'strip'
You called `pyjokes.get_jokes()` which returns a list of jokes, but then attempted to apply a string method (like `.strip()`) directly to this list instead of its individual elements.
fix
Iterate over the list to process each joke string, or use `pyjokes.get_joke()` if you only need a single joke. Example: `for joke in pyjokes.get_jokes(): print(joke.strip())`
Upgrade
Version history
0.8.3latest on PyPI · released Aug 10, 2024
Audit
Dependencies

No dependency data recorded yet.

Agent activity
31 hits · last 30 days
node
29
OpenAI (training)
1
Resources
pyjokes — pip install pyjokes · libregistry