Elegant debuging module
Project description
Nezu
Elegant debug module
-
Python Code Example
# file.py from nezu import say x = 13 say('x') # Prints debug info.
-
Bash Commands to Debug
export NEZU_SEEK=1 python file.py @4 l x:int => 13
Table of Contents
Installation
-
Pip
python -m pip install nezu
-
Poetry
python -m poetry add nezu
Usage
- Inspect variable using function say in your code.
- Configure Nezu to show output.
- Interpret output and debug.
Output Interpretation
@7 b print:function => Prints the values to a stream, or to sys...
│ │ │ │ │
│ │ │ │ └─ Value of inspected variable
│ │ │ │
│ │ │ └─────────────── Type of inspected variable.
│ │ │
│ │ └───────────────────── Name of inspected variable.
│ │
│ └─────────────────────── Scope of inspected variable.
│ l:local, g:global, b:build-in, u:undefined
|
└───────────────────────── Line number of inspection.
Function say
Inspect scopes and values of given keys (variable names etc.).
-
Args
-
*keys:strNames of variables to inspect
-
note:str = NoneOptional comment. Ignored if equal to None.
-
hide:int = 1This argument is compared with
nezu.seek. Ifnezu.seek >= hidethis debug inspection will be displayed. If hide <= 0, this message will be displayed by default.
-
-
Python Code Example
# file.py from nezu import say egg = 3 ham = int() spam = {'spam':'bacon'} say('egg') # Works on simple variables. say('ham.real') # Works on attributes. say('print') # Works on functions and build-ins. say('spam["spam"]') # DOES NOT work on keys and indexes yet.
-
Note
Output of
sayfunction is hidden by default. If you want to see what nezu has to say you need to configure env varNEZU_SEEKwith value of1or more.
Config
Module nezu creates nezu object that has config attributes used by function say.
- Attributes
nezu.seek:int = 0Compared tosayargumenthide, ifnezu.seek >= hidethensaywill be printed.nezu.color:bool = FalseDetermines if output ofsayfunction should be colored.nezu.lock:bool = FalseIfnezu.lock = True, this config cannot be changed later, during runtime.
Env Vars Config
If you want to use default config method, change your env vars in terminal and run Python script.
-
Bash
export NEZU_SEEK=1 export NEZU_COLOR=1 export NEZU_LOCK=0 python file.py
-
PowerShell
$env:NEZU_SEEK = 1 $env:NEZU_COLOR = $True $env:NEZU_LOCK = $True python file.py
JSON Config
If you don't want to use env vars as config, you can call nezu.json() to read config data from json file.
It will search for key nezu inside chosen file.
-
Args
path:str = 'nezu.json'- path of config file
-
Example Python Code
from nezu import nezu, say nezu.json('my/json/file.json')
-
Example Config File
"nezu": { "seek": 1, "color": true, "locked": false }
Hardcoded Config
If you don't want to use env vars as config you can also call object nezu like function to make hardcoded config.
-
Args
seek:int = 0- debug levelcolor:bool = False- output coloringlock:bool = False- lock this config
-
Example
# file.py from nezu import nezu, say nezu(1, True, False) ...
-
Tip
There is no build-in support for yaml, toml or .env in nezu This is so nezu can stay free of dependencies. However you can use hardcoded config to pass data from any config file.
Coloring output
By default nezu output is monochrome. If your terminal of choise support coloring you can change that.
-
Example Bash Command
export NEZU_COLOR=1 python file.py
-
Example PowerShell Command
$env:NEZU_COLOR = $True python file.py
-
Example JSON Config File
"nezu": { "color": true, }
-
Example Hardcoded Config
from nezu import nezu, say nezu(color = True) ...
Hiding Output
Function say() can be hidden more by hide parameter. By default only say calls with hide <= nezu.seek will be printed. In examples bellow only says hidden up to level 3 are displayed.
-
Python Code Example
#file.py from nezu import say say('egg', hide=1) say('ham', hide=2) say('spam', hide=3) say('bacon', hide=4) say('lobster', hide=5)
-
Bash Example
export NEZU_SEEK=3 python file.py @4 u egg @5 u ham @6 u spam
-
PowerShell Example
$ENV:NEZU_SEEK = 3 python file.py @4 u egg @5 u ham @6 u spam
-
JSON File Example
"nezu": { "seek": 3 }
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nezu-0.3.14.tar.gz.
File metadata
- Download URL: nezu-0.3.14.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.11.7 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
13c2ba66943b62016fa30fff01bd57d5fa4037d48cdad7ae1d843eadd4cbca5c
|
|
| MD5 |
902264e3ed9e272255f27b87a1095377
|
|
| BLAKE2b-256 |
e6b09cef1da3ea3abefaa20561cf991f3073c32b7c23123233d055eacabaf215
|
File details
Details for the file nezu-0.3.14-py3-none-any.whl.
File metadata
- Download URL: nezu-0.3.14-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.11.7 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4103f7e39c1dbf3af92606d8bfe52c5af57d7efd924721a95648646fba21516f
|
|
| MD5 |
d18d02b1fa1e4554c821ba172e23c3cb
|
|
| BLAKE2b-256 |
d32c2b9f8974b48a3079a02e554b16b2d33d53f7d69cdac5e359823bd86f1ddb
|