A lightweight nested printing, for all your function within loops within function needs
Installation
You can install using pip with
pip3 install --user nested_print
Usage
This functions like an extension to the python print API, so you can use end and sep and everything else listed in the print API. Only additional fields are added:
level
nest
Basic Example
from nested_print import nprint
nprint("hi", "there", level=2) # prints \t\t hi there
nprint("hi", "there", level=1, nest="--") # prints -- hi there
Motivation Example
from nested_print import nprint
nprint("here")
for i in range(10):
nprint(i, level=1)
for j in range(3):
nprint(j, level=2)
which prints
here
0
0
1
2
1
0
1
2
...
so it becomes easier for me to debug
API
level
This describes how many “nest” or “indentations” to add. Setting level=0 is the same as using print. level=1 indents the output once, such that a \t is added in front when printing.
nest
By default, nest is set to \t. This value can be set if you want to modify the indentation. For example, instead of using \t, you can set nest=" " to just add 2 spaces as the indentation. Or set nest="--" to set two dashes for every indentation.
Versions
1.0.x * Original publish and its fixes
Metadata
Release files for nprint 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nprint-1.0.0-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Release files / nprint-1.0.0-py2.py3-none-any.whl
| Download URL | nprint-1.0.0-py2.py3-none-any.whl |
|---|---|
| Size | 3.9 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
2ccd8e7b1cd82764bad39f66257dfe96694a6221a0859adeb79857d70c219ba6
|
|
BLAKE2b-256 checksum How to use checksums |
22e715f03285cb140d2556ffbc4e5e16ada31246afb955f1951ac3bc953feb80
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |