Save a few seconds and a few keystrokes with every print statement! 😎
print ("veryLongVariableName : ", veryLongVariableName)
from smartprint import smartprint as sprint
veryLongVariableName = 25
sprint (veryLongVariableName)
veryLongVariableName : 25
from smartprint import smartprint as sprint
import numpy as np
a = [1,22,31]
sprint (a, len(a))
sprint (np.random.rand())
a, len(a) : [1, 22, 31] 3
np.random.rand() : 0.649617730484109
2. smartprint
includes pretty print (through pprint
module and colored prints through rich
module) for lists and dicts as shown below:
d = {-1:"dictionaries", 0: "are", 100:"keys", "boolean":[True, False],
6:"printed", 50:" with sorted", "Nishant":"Kumar", \
"numbers":[1,100,-2000,12]}
sprint (d)
As suggested by user @nickdelgrosso in Issue 7, if
from smartprint import smartprint as print
is used, smartprint can be used as an in-place print replacement. Alternatively, it can be used to override the existing print statements without touching any other parts of the code.
pip install smartprint
Please feel free to start a pull request/ raise an issue.