Skip to main content

print info about object (attributes+properties+methods results)

Project description

object_info

Designed to print info about object (properties+methods results)

But why? if we can use debugger directly? Reason:

  1. 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
  2. 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
  1. useful if you wish to see info from remote source if connecting directly over ssh for example

Features

  1. print all properties and methods results
  2. show exceptions on methods and properties
  3. skip names by full/part name

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 *

GUIDE

USAGE

from object_info import *

class Cls0:
    attr1=1

class Cls1:
    attrMissFullName = "attrMissFullName"
    attrMissPartName = "MissPartName"
    attrNone = None
    attrInt = 1
    attrFloat = 2
    attrClass = Cls0
    attrObj = Cls0()
    attrSet = {1,2,3}
    attrList = [1,2,3]
    attrDict = {1:1}
    attrListObj = [Cls0(), Cls0(), 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())
"""
==========print=====================================================================================
str=<__main__.Cls1 object at 0x000002103087D130>
repr=<__main__.Cls1 object at 0x000002103087D130>
----------properties_ok-----------------------------------------------------------------------------
__dict__                 	dict      :{}
__doc__                  	NoneType  :None
__module__               	str       :__main__
__weakref__              	NoneType  :None
attrDict                 	dict      :{1: 1}
attrFloat                	int       :2
attrInt                  	int       :1
attrList                 	list      :[1, 2, 3]
attrListObj              	list      :[<__main__.Cls0 object at 0x000002103087C8F0>, <__main__.Cls0 object at 0x000002103087C950>, 1]
attrNone                 	NoneType  :None
attrSet                  	set       :{1, 2, 3}
propertyInt              	int       :1
----------properties_exx----------------------------------------------------------------------------
propertyExx              	Exception :exxMsg
----------objects-----------------------------------------------------------------------------------
attrObj                  	Cls0      :<__main__.Cls0 object at 0x0000021030873440>
----------methods_ok--------------------------------------------------------------------------------
__class__                	Cls1      :<__main__.Cls1 object at 0x000002103087DF70>
__dir__                  	str       :['__module__', 'attrMissFullName', 'attrMissPartName', 'attrNone', 'attrInt', 'attrFloat', 'attrC...
__getstate__             	NoneType  :None
__hash__                 	int       :141784808723
__repr__                 	str       :<__main__.Cls1 object at 0x000002103087D130>
__sizeof__               	int       :16
__str__                  	str       :<__main__.Cls1 object at 0x000002103087D130>
__subclasshook__         	NotImplementedType:NotImplemented
attrClass                	Cls0      :<__main__.Cls0 object at 0x000002103087E120>
methInt                  	int       :1
----------methods_exx-------------------------------------------------------------------------------
__eq__                   	TypeError :expected 1 argument, got 0
__format__               	TypeError :Cls1.__format__() takes exactly one argument (0 given)
__ge__                   	TypeError :expected 1 argument, got 0
__getattribute__         	TypeError :expected 1 argument, got 0
__gt__                   	TypeError :expected 1 argument, got 0
__le__                   	TypeError :expected 1 argument, got 0
__lt__                   	TypeError :expected 1 argument, got 0
__ne__                   	TypeError :expected 1 argument, got 0
methExx                  	Exception :exxMsg
----------skipped-----------------------------------------------------------------------------------
attrMissFullName
----------skipped_danger----------------------------------------------------------------------------
__delattr__
__init__
__init_subclass__
__new__
__reduce__
__reduce_ex__
__setattr__
attrMissPartName
====================================================================================================
"""

ObjectInfo(Cls1()).print(only_names_include="attr")
"""
==========PRINT=====================================================================================
INCLUDE names [attr]
str=<__main__.Cls1 object at 0x000001EE4121E720>
repr=<__main__.Cls1 object at 0x000001EE4121E720>
----------properties_ok-----------------------------------------------------------------------------
attrDict                 	dict      :{1: 1}
attrFloat                	int       :2
attrInt                  	int       :1
attrList                 	list      :[1, 2, 3]
attrListObj              	list      :[<__main__.Cls0 object at 0x000001EE4121E0F0>, <__main__.Cls0 object at 0x000001EE4121E510>, 1]
attrNone                 	NoneType  :None
attrSet                  	set       :{1, 2, 3}
----------properties_exx----------------------------------------------------------------------------
----------objects-----------------------------------------------------------------------------------
attrObj                  	Cls0      :<__main__.Cls0 object at 0x000001EE41280E90>
----------methods_ok--------------------------------------------------------------------------------
attrClass                	Cls0      :<__main__.Cls0 object at 0x000001EE40FCA4E0>
----------methods_exx-------------------------------------------------------------------------------
__getattribute__         	TypeError :expected 1 argument, got 0
----------skipped-----------------------------------------------------------------------------------
attrMissFullName
----------skipped_danger----------------------------------------------------------------------------
__delattr__
__setattr__
attrMissPartName
====================================================================================================
"""

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

object_info-0.1.1.tar.gz (8.9 kB view hashes)

Uploaded Source

Built Distribution

object_info-0.1.1-py3-none-any.whl (8.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page