Include the variable name in print statements
Project description
smartprint
Save a few seconds and a few keystrokes with every print statement! 😎
Usual print statment:
print ("veryLongVariableName : ", veryLongVariableName)
Enter smart print:
from smartprint import smartprint as sprint
veryLongVariableName = 25
sprint (veryLongVariableName)
Output:
veryLongVariableName : 25
Examples:
1. smartprint works with multiple variables and different kinds of objects
from smartprint import smartprint as sprint
import numpy as np
a = [1,22,31]
sprint (a, len(a))
sprint (np.random.rand())
Output:
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:
2 (a) List example
d = {-1:"dictionaries", 0: "are", 100:"keys", "boolean":[True, False],
6:"printed", 50:" with sorted", "Nishant":"Kumar", \
"numbers":[1,100,-2000,12]}
sprint (d)
Output:
In place print replacement
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.
Installation
pip install smartprint
Issues
Please feel free to start a pull request/ raise an issue.
Code coverage plot
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 smartprint-1.0.5.tar.gz.
File metadata
- Download URL: smartprint-1.0.5.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0be8e0c6e95aa7d6f8bf0a5cf8e75923c034562cb0f4b916262683dab5b03ad0
|
|
| MD5 |
0ef2df49dacfd8f41b1785a65d25f755
|
|
| BLAKE2b-256 |
7a4b68b76d1e092b843d0a037caedd54ef8875df0a3d57d4083eabf060f1def4
|
File details
Details for the file smartprint-1.0.5-py3-none-any.whl.
File metadata
- Download URL: smartprint-1.0.5-py3-none-any.whl
- Upload date:
- Size: 3.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f9d937bae02073932f01cce8f7bec1527daced978b1565a8267f6c7166c8f99
|
|
| MD5 |
d634b3a4ec17d47d5dd8e3b9ea95c471
|
|
| BLAKE2b-256 |
cf04db8b8a23f6a00430e1f8987aaa7184b0fcdd07a1fdf540aee331f0f419fd
|