Python Pyjokes Module

Effie Njoki
1 min readJun 27, 2023

--

Did you know that you could create one-line programming jokes using a python library called pyjokes ?

Let me show you how..

Install:

pip install pyjokes

Usage:

Run $ pyjokes on your terminal to get a random joke:

$ pyjokes
Waiter: Would you like coffee or tea? Programmer: Yes.

To get jokes from a specific category, use the -c flag. Options:

-c neutral [default] (neutral geek jokes)
-c chuck (Chuck Norris geek jokes)
-c all (all jokes)
-c twister

You can also make your project more interesting by adding jokes in your projects in just one line, here is how..

Import the pyjokes module in your Python file and use the get_jokes function to easily drop a random joke into your program:

import pyjokes

print(pyjokes.get_joke())

Pyjokes is a simple and harmless way to make you and your mates smile. There are more ways to play around with the module, like adding the command to your shell startup script and getting a geeky joke every time you fire up your terminal.

--

--