ha
A medley of joke datasets and tools.
To install: pip install ha
Examples
Joke datasets
List the datasets (keys):
import ha
list(ha.joke_datasets)
# ['reddit_jokes', 'stupidstuff', 'wocka']
Get a dataset. The datasets are lists of dicts.
reddit_jokes = ha.joke_datasets['reddit_jokes']
reddit_jokes[1000:1003]
[{'body': 'Why did the chicken cross the road? ...',
'id': '5tdwk4',
'score': 1,
'title': 'Why did the chicken cross the road?'},
{'body': 'A little boy goes to his dad and asks, ..."',
'id': '5tdssi',
'score': 123,
'title': 'What is Politics?'},
{'body': 'A teacher asked her 4th grade students a ...',
'id': '5tdsmb',
'score': 40,
'title': 'A teacher asked her students...'}]
The values of the joke_datasets mapping are lists of dicts containing the joke
data. For example, to list the datasets and their sizes, you'd do:
print({k: len(v) for k, v in ha.joke_datasets.items()})
# {'reddit_jokes': 194553, 'stupidstuff': 3773, 'wocka': 10019}
Get an aggregate of all the datasets.
len(jokes)
208345
The keys of the aggregate come as (dataset_name, id) pairs.
Let's look at the first two and the first last keys.
print(list(jokes)[:2])
print(list(jokes)[-2:])
[('reddit_jokes', '5tz52q'), ('reddit_jokes', '5tz4dd')]
[('wocka', 18199), ('wocka', 18200)]
Get a joke (data) by using it's key:
jokes['wocka', 18199]
Joke (vendorized) tools
pyjokes
Install: pip install ha[pyjokes] (or independently, doing pip install pyjokes).
from ha.pyjokes import get_joke
get_joke() # gets a random joke, with default characteristics
"Two bytes meet. The first byte asks, 'Are you ill?' The second byte replies, 'No, just feeling a bit off.'"
laugh
import laugh
thor_joke = laugh.NamedJokes(name='Thor')
thor_joke() # random joke
'The stock market monitors Thor.'
thor_joke('god') # random joke containing the word "god" (or None if none found)
'The guy that God prays to goes to Thor for forgiveness!'
Metadata
Release files for ha 0.0.10
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ha-0.0.10.tar.gz | 5.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ha-0.0.10-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.6 kB
Release files / ha-0.0.10.tar.gz
| Download URL | ha-0.0.10.tar.gz |
|---|---|
| Size | 5.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7c4b24af46ce5d54fa2b350e4e07d76478f73dcd6836aa4223436a86da073b78
|
|
BLAKE2b-256 checksum How to use checksums |
62533061675c3c29c2010d4b72876e70070ec7b608c577910179732c80a4f9c7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","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 / ha-0.0.10-py3-none-any.whl
| Download URL | ha-0.0.10-py3-none-any.whl |
|---|---|
| Size | 5.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
71a2aec9125aabecf9f79d89f09b55f3acc824f81f080df87a23dcfb4f072b79
|
|
BLAKE2b-256 checksum How to use checksums |
ee7c5ec6717e5653e5a267b8cfb5f12520ce90b63e9257f1b8f21464e7ef2849
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|