Local development tool for logs printing.
https://github.com/Sobolev5/simple-print
To install run:
pip install simple-print
- Variable value on the first line, metadata (type, file, line, function, time) on the second line
- Clickable file paths in terminal output — Cmd+click (macOS) or Ctrl+click (Linux/Windows) to jump to source
- Colors, backgrounds, attributes, indentation
Print variables with its names:
master = "yoda" # variable name master
sprint(master)
sprint(master, c="magenta")
sprint(master, c="white", b="on_blue")
sprint(master, c="blue", b="white", a="underline")
sprint(master, c="blue", b="on_white", a="bold", p=True)
master_as_s = sprint(master, s=True) # return as string
master_as_s_with_path = sprint(master, s=True, p=True) # return as string with path to file
ccolor [grey, red, green, yellow, blue, magenta, cyan, white].
bbackground [on_grey, on_red, on_green, on_yellow, on_blue, on_magenta, on_cyan].
aattribute [bold, dark, underline, blink, reverse, concealed].
ppath [True/False] with path to file.
llight [True/False] print without fn name and lineno (shortcut lprint).
iindent [1..40].
sstring [True/False] return as string.
rreturn [True/False] print and return as string.
fforce print [True/False] ignore SIMPLE_PRINT_ENABLED=False for docker production logs for example.
streamoutput stream [stdout, stderr, null]. stdout by default. null means no print.
Indent print:
def test_indent():
fruits = ["lemon", "orange", "banana"]
sprint(fruits, c="green")
for fruit in fruits:
sprint(fruit, c="yellow", i=4)Light version of sprint (no metadata line). Also available as lsprint for backward compatibility.
master = "yoda" # variable name master
lprint(master)
Minified error traceback with box frame.
from simple_print import SprintErr
bob = []
with SprintErr(l=30):
bob[2] # pretty error traceback (show 30 lines)
Pretty print dict with box frame.
from simple_print import spprint
spprint({"hello": "world", "lorem": "ipsum"})
spprint({"hello": "world", "lorem": "ipsum"}, i=20) # with indent
Stop printing on production:
export SIMPLE_PRINT_ENABLED=False
pytest -s




