Skip to main content

xxkcd

An (unofficial) Python wrapper around xkcd APIs

Python 2 and 3 compatible. Requires an internet connection.

Examples

For full usage, see the wiki.

>>> from xxkcd import xkcd, WhatIf
>>> x = xkcd(353)
>>> x
xkcd(353)
>>> print(x.transcript)
[[ Guy 1 is talking to Guy 2, who is floating in the sky ]]
Guy 1: You're flying! How?
Guy 2: Python!
Guy 2: I learned it last night! Everything is so simple!
Guy 2: Hello world is just 'print "Hello, World!" '
Guy 1: I dunno... Dynamic typing? Whitespace?
Guy 2: Come join us! Programming is fun again! It's a whole new world up here!
Guy 1: But how are you flying?
Guy 2: I just typed 'import antigravity'
Guy 1: That's it?
Guy 2: ...I also sampled everything in the medicine cabinet for comparison.
Guy 2: But i think this is the python.
{{ I wrote 20 short programs in Python yesterday.  It was wonderful.  Perl, I'm leaving you. }}
>>> print(x.title)
Python
>>> print(x.alt)
I wrote 20 short programs in Python yesterday.  It was wonderful.  Perl, I'm leaving you.
>>> what_if = WhatIf(1)
>>> print(what_if.title)
Relativistic Baseball
>>> print(what_if.question)
What would happen if you tried to hit a baseball pitched at 90% the speed of light?
>>> print(what_if.attribute)
- Ellen McManis
from xxkcd import xkcd, WhatIf
# Get random comic
xkcd.random()

# Get number of latest comic
xkcd.latest()

# Get random What If? article
WhatIf.random()

# Get number of latest What If? article
WhatIf.latest()

Installing

From PyPI

$ pip install xxkcd

From source

$ git clone 'https://github.com/MitalAshok/xxkcd.git'
$ python ./xxkcd/setup.py install

Release files for xxkcd 1.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xxkcd 1.4.0
File Size Uploaded
xxkcd-1.4.0.tar.gz 673.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for xxkcd 1.4.0
File Interpreter ABI Platform
xxkcd-1.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 1.4 MB

Release files / xxkcd-1.4.0.tar.gz

Download URL xxkcd-1.4.0.tar.gz
Size 673.6 kB
Tags Source
SHA-256 checksum
How to use checksums
18534edf11de8f682aa499d41e5e9871476f2dfb4bafdeff8f189e0c947fef31
BLAKE2b-256 checksum
How to use checksums
0542f8e3844868977a8af32e352040cd836499c52d2ae95cb11bc32644ad0cb6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.20.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.6

Release files / xxkcd-1.4.0-py3-none-any.whl

Download URL xxkcd-1.4.0-py3-none-any.whl
Size 677.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
26f4ffc7c45482dcbbcd12e65b86ed86f1dfcf664c3fdfcf9838672e90649248
BLAKE2b-256 checksum
How to use checksums
7ffa5921954878fc41a6713beee082b484e1648af93a038f9d2aa6e9ce9cdaf6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.20.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.6

Release history Release notifications | RSS feed

This release

1.4.0 This release

2 release files

1.3.5

2 release files

1.3.4

2 release files

1.3.3

2 release files

1.3.2

2 release files

1.3.1

1 release file

1.3.0

1 release file

1.2.2

1 release file

1.2.1

1 release file

1.2.0

1 release file

1.0.2

1 release file

1.0.1

1 release file

1.0.0

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

0.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page