Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/joeyism/py-nprint
A lightweight nested printing, for all your function within loops within function needs
https://github.com/joeyism/py-nprint
debug function indent loop loops nest nested nprint print python tool
Last synced: 27 days ago
JSON representation
A lightweight nested printing, for all your function within loops within function needs
- Host: GitHub
- URL: https://github.com/joeyism/py-nprint
- Owner: joeyism
- License: other
- Created: 2017-12-17T04:50:34.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2017-12-17T05:08:35.000Z (about 7 years ago)
- Last Synced: 2024-10-16T22:10:41.882Z (3 months ago)
- Topics: debug, function, indent, loop, loops, nest, nested, nprint, print, python, tool
- Language: Python
- Homepage:
- Size: 5.86 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Nested Print
A lightweight nested printing, for all your function within loops within function needs## Installation
You can install using pip with```bash
pip3 install --user nprint
```## 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](https://docs.python.org/3/library/functions.html#print). Only additional fields are added:* level
* nest### Basic Example
```python
from nprint import nprintnprint("hi", "there", level=2) # prints \t\t hi there
nprint("hi", "there", level=1, nest="--") # prints -- hi there
```### Motivation Example
```python
from nprint import nprintnprint("here")
for i in range(10):
nprint(i, level=1)
for j in range(3):
nprint(j, level=2)
```which prints
```bash
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