https://github.com/akuhn/print-considered-harmful
Switch from print to debugger() and never look back!
https://github.com/akuhn/print-considered-harmful
debug debugging printf
Last synced: 15 days ago
JSON representation
Switch from print to debugger() and never look back!
- Host: GitHub
- URL: https://github.com/akuhn/print-considered-harmful
- Owner: akuhn
- Created: 2018-03-31T19:51:00.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-04-20T14:40:23.000Z (about 8 years ago)
- Last Synced: 2025-12-15T22:23:42.713Z (6 months ago)
- Topics: debug, debugging, printf
- Language: Python
- Size: 11.7 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
Awesome Lists containing this project
README
# 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