{"id":10099,"library":"pyjokes","title":"PyJokes","description":"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.","status":"active","version":"0.8.3","language":"en","source_language":"en","source_url":"https://github.com/pyjokes/pyjokes","tags":["jokes","humor","developer-tools","cli"],"install":[{"cmd":"pip install pyjokes","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"symbol":"get_joke","correct":"from pyjokes import get_joke"},{"symbol":"get_jokes","correct":"from pyjokes import get_jokes"}],"quickstart":{"code":"import pyjokes\n\n# Get a random programmer joke\nprogrammer_joke = pyjokes.get_joke(category='programmer')\nprint(\"Programmer Joke:\", programmer_joke)\n\n# Get a random neutral joke in German\ntry:\n    german_joke = pyjokes.get_joke(language='de', category='neutral')\n    print(\"German Neutral Joke:\", german_joke)\nexcept Exception as e:\n    print(f\"Could not fetch German joke (might not be available): {e}\")\n\n# Get a list of all jokes (careful, can be long!)\n# all_jokes_list = pyjokes.get_jokes(category='all', language='en')\n# print(f\"First 3 jokes from list: {all_jokes_list[:3]}\")","lang":"python","description":"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."},"warnings":[{"fix":"Use supported categories like 'programmer', 'neutral', or 'all'. You can inspect `pyjokes.CATEGORIES` for a definitive list of current options.","message":"The `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.","severity":"breaking","affected_versions":">=0.8.0"},{"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.","message":"Using `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.","severity":"gotcha","affected_versions":"All versions"},{"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)`.","message":"The 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.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Install the package using pip: `pip install pyjokes`","cause":"The `pyjokes` library has not been installed in the current Python environment.","error":"ModuleNotFoundError: No module named 'pyjokes'"},{"fix":"Use one of the currently supported categories: 'programmer', 'neutral', or 'all'. You can check `pyjokes.CATEGORIES` for a definitive list.","cause":"An unsupported joke category was requested. The 'chuck' category was removed in recent versions, but may still appear in older documentation or examples.","error":"KeyError: 'chuck'"},{"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())`","cause":"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.","error":"AttributeError: 'list' object has no attribute 'strip'"}]}