CowExcept
Spice up those exceptions with cowexcept!
______________________________________
< NameError: name 'baz' is not defined >
--------------------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
Install
pip install cowexcept
Usage
All you have to do to get started is activate cowexcept and then any
exceptions whenceforth will be in beautiful cowsay format:
>>> import cowexcept
>>> cowexcept.activate()
>>> 1/0
_____________________________________
/ Traceback (most recent call last): \
| File "...", line 1, in ... |
| 1 / 0 |
\ ZeroDivisionError: division by zero /
-------------------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
If no cow or cow file is specified, cows are chosen at random (from cowsay -l
from the python-cowsay package).
When activating cowexcept, a cow name can be provided to set the cow for all
exceptions:
>>> import cowexcept
>>> cowexcept.activate("elephant-in-snake")
>>> 1 / 0
_____________________________________
/ Traceback (most recent call last): \
| File "...", line 1, in ... |
| 1 / 0 |
| ~~^~~ |
\ ZeroDivisionError: division by zero /
-------------------------------------
\
\ ....
........ .
. .
. .
......... .......
..............................
To deactivate cowexcept call cowexcept.deactivate() and any exceptions will
be handled with Python's default exception handler.
Using Your Own Cows
You can specify alternative cows to display using the set_cow
and set_cow_from_file functions.
The set_cow function takes the name of any cowfile included in
the python-cowsay package and sets the
cow to be displayed in exceptions.
>>> import cowexcept
>>> cowexcept.activate()
>>> cowexcept.set_cow("dragon-and-cow")
>>> 1 / 0
_____________________________________
/ Traceback (most recent call last): \
| File "...", line 1, in ... |
| 1 / 0 |
| ~~^~~ |
\ ZeroDivisionError: division by zero /
-------------------------------------
\ ^ /^
\ / \ // \
\ |\___/| / \// .\
\ /O O \__ / // | \ \ *----*
/ / \/_/ // | \ \ \ |
@___@` \/_ // | \ \ \/\ \
0/0/| \/_ // | \ \ \ \
0/0/0/0/| \/// | \ \ | |
0/0/0/0/0/_|_ / ( // | \ _\ | /
0/0/0/0/0/0/`/,_ _ _/ ) ; -. | _ _\.-~ / /
,-} _ *-.|.-~-. .~ ~
\ \__/ `/\ / ~-. _ .-~ /
\____(oo) *. } { /
( (--) .----~-.\ \-` .~
//__\\ \__ Ack! ///.----..< \ _ -~
// \\ ///-._ _ _ _ _ _ _{^ - - - - ~
You can also specify custom cows by passing in a cowfile or TextIO stream to
the set_cow_from_file function:
>>> from io import StringIO
>>> import cowexcept
>>> cowexcept.set_cow_from_file(StringIO("""
... $the_cow = <<EOC;
... $thoughts
... $thoughts
... ___
... (o o)
... ( V )
... /--m-m-
... EOC
... """))
>>> cowexcept.activate()
>>> 1 / 0
_____________________________________
/ Traceback (most recent call last): \
| File "...", line 1, in ... |
| 1 / 0 |
| ~~^~~ |
\ ZeroDivisionError: division by zero /
-------------------------------------
\
\
___
(o o)
( V )
/--m-m-
Metadata
Release files for cowexcept 1.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cowexcept-1.4.0.tar.gz | 7.2 kB | Without provenance | Details for cowexcept-1.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cowexcept-1.4.0-py3-none-any.whl | Python 3 | none | any | Details for cowexcept-1.4.0-py3-none-any.whl |
Total release size: 14.7 kB
Release files / cowexcept-1.4.0.tar.gz
| Download URL | cowexcept-1.4.0.tar.gz |
|---|---|
| Size | 7.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9cd913cf871563d0b257c194759fd540d001620f7f67c13d90c2277dc385136a
|
|
BLAKE2b-256 checksum How to use checksums |
8804bb6aba6fceb4b66f9f4c20d6f5b24fd27478c64a21d7221fa92b7e561c39
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.13
|
Release files / cowexcept-1.4.0-py3-none-any.whl
| Download URL | cowexcept-1.4.0-py3-none-any.whl |
|---|---|
| Size | 7.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
85b00ed967f8a424c77b56d9efd0e8bd936e68656a749de58db123a6605a4c97
|
|
BLAKE2b-256 checksum How to use checksums |
993e457a8ff27660b628a90bf6ee203a7fcbf802630eb7ddd3b9f64366c518ad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.13
|
Security for cowexcept 1.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.