print info about object (attributes+properties+methods results)
Project description
object_info (v0.1.14)
DESCRIPTION_SHORT
print info about object (attributes+properties+methods results)
DESCRIPTION_LONG
Designed to print info about object (properties+methods results)
But why? if we can use debugger directly?
Reason:
- to get and save standard text info,
it useful to keep this info for future quick eye sight without exact condition like other OS or device/devlist/configuration - in debugger we cant see result of methods!
try to see for example information from platform module! it have only methods and no one in object tree in debugger!
import platform
obj = platform
print(platform.platform())
pass # place debug point here
- Useful if you wish to see info from remote source if connecting directly over ssh for example
Features
- print all properties and methods results
- show exceptions on methods and properties
- skip names by full/part names
- separated collections in groups
License
See the LICENSE file for license rights and limitations (MIT).
Release history
See the HISTORY.md file for release history.
Installation
pip install object-info
Import
from object_info import *
USAGE EXAMPLES
See tests and sourcecode for other examples.
1. example1.py
from object_info import *
class Cls0:
attr1=1
class Cls1:
attrSkipFullName = "attrSkipFullName"
attrSkipPartName = "SkipPartName"
attrNone = None
attrInt = 1
attrFloat = 2.2
attrClass = Cls0
attrObj = Cls0()
attrSet = {1,2,3}
attrList = [1,2,3]
attrTuple = (1,2,3)
attrDict = {1:1}
attrListObj = [*[Cls0(), ] * 5, 1]
@property
def propertyInt(self):
return 1
@property
def propertyExx(self):
raise Exception("exxMsg")
def methInt(self):
return 1
def methExx(self):
raise Exception("exxMsg")
# ObjectInfo(Cls1()).print()
# ObjectInfo().print(Cls1())
ObjectInfo(Cls1()).print(
_log_iter=True,
only_names_include=[],
skip_fullnames=["attrSkipFullName", ],
skip_partnames=["SkipPartName", ],
hide_build_in=None,
hide_skipped=None,
)
"""
==========OBJECTINFO.PRINT==========================================================================
str(source)=<__main__.Cls1 object at 0x00000160168F6F10>
repr(source)=<__main__.Cls1 object at 0x00000160168F6F10>
----------SETTINGS----------------------------------------------------------------------------------
skip_fullnames=['attrSkipFullName']
skip_partnames=['SkipPartName']
only_names_include=[]
hide_build_in=None
hide_skipped=None
_log_iter=True
----------_log_iter(wait last touched)--------------------------------------------------------------
1 __class__
2 __delattr__
3 __dict__
4 __dir__
5 __doc__
6 __eq__
7 __format__
8 __ge__
9 __getattribute__
10 __getstate__
11 __gt__
12 __hash__
13 __init__
14 __init_subclass__
15 __le__
16 __lt__
17 __module__
18 __ne__
19 __new__
20 __reduce__
21 __reduce_ex__
22 __repr__
23 __setattr__
24 __sizeof__
25 __str__
26 __subclasshook__
27 __weakref__
28 attrClass
29 attrDict
30 attrFloat
31 attrInt
32 attrList
33 attrListObj
34 attrNone
35 attrObj
36 attrSet
37 attrSkipFullName
38 attrSkipPartName
39 attrTuple
40 methExx
41 methInt
42 propertyExx
43 propertyInt
----------properties_ok-----------------------------------------------------------------------------
__dict__ dict :{}
__doc__ NoneType :None
__module__ str :__main__
__weakref__ NoneType :None
attrFloat float :2.2
attrInt int :1
attrNone NoneType :None
propertyInt int :1
attrDict dict :{1: 1}
attrList list :[1, 2, 3]
attrListObj list :
Cls0 :<__main__.Cls0 object at 0x00000160168F6E10>
Cls0 :<__main__.Cls0 object at 0x00000160168F6E10>
Cls0 :<__main__.Cls0 object at 0x00000160168F6E10>
Cls0 :<__main__.Cls0 object at 0x00000160168F6E10>
Cls0 :<__main__.Cls0 object at 0x00000160168F6E10>
:...
attrSet set :{1, 2, 3}
attrTuple tuple :(1, 2, 3)
----------properties_exx----------------------------------------------------------------------------
propertyExx Exception :Exception('exxMsg')
----------methods_ok--------------------------------------------------------------------------------
__class__ Cls1 :str(<__main__.Cls1 object at 0x0000016016C0AC90>)
Cls1 :repr(<__main__.Cls1 object at 0x0000016016C0AC90>)
__dir__ list :
str :__module__
str :attrSkipFullName
str :attrSkipPartName
str :attrNone
str :attrInt
:...
__getstate__ NoneType :None
__hash__ int :94512936689
__repr__ str :<__main__.Cls1 object at 0x00000160168F6F10>
__sizeof__ int :24
__str__ str :<__main__.Cls1 object at 0x00000160168F6F10>
__subclasshook__ NotImplementedType:str(NotImplemented)
NotImplementedType:repr(NotImplemented)
attrClass Cls0 :str(<__main__.Cls0 object at 0x0000016016C0AED0>)
Cls0 :repr(<__main__.Cls0 object at 0x0000016016C0AED0>)
methInt int :1
----------methods_exx-------------------------------------------------------------------------------
__eq__ TypeError :TypeError('expected 1 argument, got 0')
__format__ TypeError :TypeError('Cls1.__format__() takes exactly one argument (0 given)')
__ge__ TypeError :TypeError('expected 1 argument, got 0')
__getattribute__ TypeError :TypeError('expected 1 argument, got 0')
__gt__ TypeError :TypeError('expected 1 argument, got 0')
__le__ TypeError :TypeError('expected 1 argument, got 0')
__lt__ TypeError :TypeError('expected 1 argument, got 0')
__ne__ TypeError :TypeError('expected 1 argument, got 0')
methExx Exception :Exception('exxMsg')
----------objects-----------------------------------------------------------------------------------
attrObj Cls0 :str(<__main__.Cls0 object at 0x00000160168F6DD0>)
Cls0 :repr(<__main__.Cls0 object at 0x00000160168F6DD0>)
----------skipped_fullnames-------------------------------------------------------------------------
attrSkipFullName
----------skipped_partnames-------------------------------------------------------------------------
__delattr__
__init__
__init_subclass__
__new__
__reduce__
__reduce_ex__
__setattr__
attrSkipPartName
====================================================================================================
"""
ObjectInfo(Cls1()).print(only_names_include="attr")
"""
==========OBJECTINFO.PRINT==========================================================================
str(source)=<__main__.Cls1 object at 0x0000016016C0B0D0>
repr(source)=<__main__.Cls1 object at 0x0000016016C0B0D0>
----------SETTINGS----------------------------------------------------------------------------------
skip_fullnames=None
skip_partnames=None
only_names_include='attr'
hide_build_in=None
hide_skipped=None
_log_iter=None
----------_log_iter(wait last touched)--------------------------------------------------------------
----------properties_ok-----------------------------------------------------------------------------
attrFloat float :2.2
attrInt int :1
attrNone NoneType :None
attrSkipFullName str :attrSkipFullName
attrSkipPartName str :SkipPartName
attrDict dict :{1: 1}
attrList list :[1, 2, 3]
attrListObj list :
Cls0 :<__main__.Cls0 object at 0x00000160168F6E10>
Cls0 :<__main__.Cls0 object at 0x00000160168F6E10>
Cls0 :<__main__.Cls0 object at 0x00000160168F6E10>
Cls0 :<__main__.Cls0 object at 0x00000160168F6E10>
Cls0 :<__main__.Cls0 object at 0x00000160168F6E10>
:...
attrSet set :{1, 2, 3}
attrTuple tuple :(1, 2, 3)
----------properties_exx----------------------------------------------------------------------------
----------methods_ok--------------------------------------------------------------------------------
attrClass Cls0 :str(<__main__.Cls0 object at 0x0000016016C0B490>)
Cls0 :repr(<__main__.Cls0 object at 0x0000016016C0B490>)
----------methods_exx-------------------------------------------------------------------------------
__getattribute__ TypeError :TypeError('expected 1 argument, got 0')
----------objects-----------------------------------------------------------------------------------
attrObj Cls0 :str(<__main__.Cls0 object at 0x00000160168F6DD0>)
Cls0 :repr(<__main__.Cls0 object at 0x00000160168F6DD0>)
----------skipped_fullnames-------------------------------------------------------------------------
----------skipped_partnames-------------------------------------------------------------------------
__delattr__
__setattr__
====================================================================================================
"""
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
object_info-0.1.14.tar.gz
(9.5 kB
view hashes)
Built Distribution
Close
Hashes for object_info-0.1.14-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 69afb3b3d0610afdd05536bdca1aa76a10ffcf74e76ea5d1f7ee66c8c56b1053 |
|
MD5 | 006c969feeecde6b7e7d40f09606712c |
|
BLAKE2b-256 | e94196aa4e8fef768bb4e540112968a2b1f324a689c7983d8a98daed1b336db0 |