Print Object in Python
Project description
Print Object in Python3.x
- Print your variable/object in beautiful way
- It's easier way to print variable name & it's value
- pobj print any type of value. Like int, str, bool, list, dict, django request, dataframe, ... few more
Install with pip
pip install pobj
Upgrade with pip
pip install pobj --upgrade
I) How to implement pobj
- install package by
pip install pobj - import pobj by
from pobj import pobjin class.py - use pobj in your code as bellow standards...
pobj(your_variable)
How to use pobj
Source Code:
from pobj import pobj
class Fruits:
def get_apple_detail(self, price: float = 0.0):
result = {
'fruit': 'Apple',
'price': price or 120,
'quantity': 2,
'available': True
}
pobj(result)
return result
OutPut:
---result---type:dict---size:0.24-KB---
{
"available": true,
"fruit": "Apple",
"price": 120,
"quantity": 2
}
How to implement pobjl
- install package by
pip install pobj - import pobjl by
from pobj import pobjlin class.py - use pobjl in your code as bellow standards...
logger = pobjl('logger_name', 'logger_level')
logger.info(your_variable)
II) How to use pobjl
Source Code:
from pobj import pobjl
logger = pobjl('demo', 'info')
class Fruits:
def get_apple_detail(self, price: float = 0.0):
result = {
'fruit': 'Apple',
'price': price or 120,
'quantity': 2,
'available': True
}
logger.info(result)
return result
fruit_obj = Fruits()
fruit_obj.get_apple_detail()
OutPut:
[2021-01-31 21:55:41,000] INFO - demo - file: demo1 - fun: get_apple_detail() - LN: 14
{'fruit': 'Apple', 'price': 120, 'quantity': 2, 'available': True}
ChangeLog Version
v1.2.3 | 2021-01-31
Print object with logger | Added | Done
- by using pobjl, User also used the feature of logger, Credit goes to logging author also ;)
- we use the existing logging, We just addon on layer on it
v1.2.2 | 2020-11-30
Show size in KB | Added | Done
- display size in KB instead of bytes
- basically we convert size of object/variable bytes into KB unit
- Note: 1000 bytes = 1 KB
v1.2.1 | 2020-11-30
Also show type & size of object | Added | Done
- additionally we also print type & size of object/variable
- type it's print the which type of variable it's. Like int/str/list/...
- size it's shows the how much memory is occupy by this variable
v1.1.1 | 2020-11-29
Print Object | Added | Done
- print your object/variable
- by using simply
pobjkeyword - like: pobj(your_obj)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pobj-1.2.3.tar.gz
(3.2 kB
view details)
File details
Details for the file pobj-1.2.3.tar.gz.
File metadata
- Download URL: pobj-1.2.3.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.6.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
658d2410d0b4d8fb4d14fe841262702473d1222eeaf00531d92a1d4b6dd56b78
|
|
| MD5 |
d5b9d80e6ee54245edc65d147b188491
|
|
| BLAKE2b-256 |
8120e3412e364dc904904682e824213b11e119d6b3bb26eda97d4d1ae3b64abb
|