Print statement considered harmful
Switch from print to debugger() and never look back.
import debug debugger() # <-- breaks here
Import this module in your main file to add debugger as a builtin command.
Documentation
All functions
debugger() debugger.enable() debugger.disable() debug.wrap(function) debug.sample(function) function.samples
Calling debugger opens the ipdb debugger,
import debug debugger() # <-- breaks here
Calling debugger.disable from the ipdb prompt disables all breakpoints,
import debug debugger() # <-- breaks here # >> debugger.disable() # >> continue debugger() # <-- does not break here
Using debug.wrap sets a function breakpoint,
def fun():
pass
def example():
fun()
fun = debug.wrap(fun)
example() # <-- breaks above at definition of fun
Using debug.sample collects function arguments,
def fun(a, b=None):
return
fun = debug.sample(fun)
fun(23)
fun(42, 'hello worlds')
debugger() # <-- breaks here
# >> len(fun.samples)
# 2
# >> fun.samples
# [{0: 23, '$': 529}, {0: 42, 'b': 'hello worlds', '$': 1764}]
Using debug.log collects values,
for each in range(3):
debug.log(each)
debugger() # <-- breaks here
# >> debugger.logs
# {'example.py': {2: [0, 1, 2]}}
Installation
To install this package, run
pip install print-considered-harmful
Contributing
Bug reports and pull requests are welcome on github at, https://github.com/akuhn/print-considered-harmful
Metadata
Release files for print-considered-harmful 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 |
|---|---|---|---|---|
| print-considered-harmful-1.4.0.tar.gz | 1.8 kB | Without provenance | Details for print-considered-harmful-1.4.0.tar.gz |
Release files / print-considered-harmful-1.4.0.tar.gz
| Download URL | print-considered-harmful-1.4.0.tar.gz |
|---|---|
| Size | 1.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
894e681847f8b63531c05c4844366019d5e7e8df9d442898e5e20fbe8f440eaa
|
|
BLAKE2b-256 checksum How to use checksums |
873ea2943e57e7f02273632d4dd1bb816bf63e7f4526f025942715af9e7d5f7a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for print-considered-harmful 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.