Skip to main content

Debug Mode

Superpowers when you need them the most

Debug mode is a tiny library that puts at your fingertips powerful tools to debug your code.

What you get

If debug_mode is activated (see below) you will have the following functions accessible from everywhere:

  • ic from the icecream library. A much better print statement for debugging purposes.
  • iex a function decorator from ipdb that will start a debugger session if the decorated function raises an exception. Great for those times when you don't know exactly where things are going wrong.
  • wat from wat to allow you to more deeply inspect all your variables.

On top of that, when you go start the debugger with breakpoint() or set_trace() you will drop into ipdb, a much better pdb with wat available there too.

Lastly, debug_mode will create a folder in the current directory named _debug and will store it's path under the name debug_folder and make it globally accessible. This is great place to throw in plots, temporary files, etc.

Usage

To use it simply import it and export the DBG environment variable.

On your code you would normally have the following line sitting there and doing nothing.

import debug_mode

This has zero overhead and truly does nothing. However, 🐛 BUG ALERT 🐛, now you need all the help that you can get to sort things out. To activate debug_mode all you need to do is export DBG, it can hold any value, it just needs to be there. You could accomplish this in many ways.

On your current terminal you could do:

export DBG=1

and all subsequent runs of your code would activate debug mode. Otherwise you could use it only for the next invocation of your script:

DBG=1 python myscript.py

or if you want it always on you could export from your bashrc, zshrc...

Making Ruff happy

I personally use Ruff for all my linting. Understandably he is not to happy about all those global objects that he knows nothing about and will shout out you, e.g for using "undefined" ic.

You can add the following Ruff configuration to your pyproject.toml

[tool.ruff]
builtins = ["ic", "iex", "wat"]

If you already have a [tool.ruff] section on your pyproject just add the builtins part.

Installation

Debug mode is available on pypi:

pip install debug-mode

but you may also just want to copy the debug_mode folder into your project and add it's requirements to your project.

pip install icecream ipdb wat-inspector

Credits

Please leave a ⭐ if you find this useful in your projects.

Metadata

Release files for debug-mode 0.1.1

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

Source distribution (sdist)

Source distribution for debug-mode 0.1.1
File Size Uploaded Provenance Actions
debug_mode-0.1.1.tar.gz 3.3 kB Without provenance Details for debug_mode-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for debug-mode 0.1.1
File Interpreter ABI Platform Actions
debug_mode-0.1.1-py3-none-any.whl Python 3 none any Details for debug_mode-0.1.1-py3-none-any.whl

Total release size: 7.0 kB

Release files / debug_mode-0.1.1.tar.gz

Download URL debug_mode-0.1.1.tar.gz
Size 3.3 kB
Tags Source
SHA-256 checksum
How to use checksums
79d4217754b2c4825a370ee3a584e0fba92d8406b37769a61bb350dffc02055d
BLAKE2b-256 checksum
How to use checksums
5ff1369c2c65a010ec33557fa353ce0e4ede8c8f1829d0f11022d756929657c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.11.9 Darwin/22.6.0

Release files / debug_mode-0.1.1-py3-none-any.whl

Download URL debug_mode-0.1.1-py3-none-any.whl
Size 3.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
83ba2e01853bc7b214258d72544233561aed6b46eb885a5ac8ffd12789e7697c
BLAKE2b-256 checksum
How to use checksums
4c77b5d2846d5acaf35b8c69484b57bad490cae6e5200ab273eea17d784fa09c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.11.9 Darwin/22.6.0

Security for debug-mode 0.1.1

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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

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