Quick Way to Debug Objects in Python

Often it is necessary to print an object to debugging log. This small utility function can help to print all  properties:

import inspect, pprint
def dprint(object):    
    props=filter(lambda t: not t[0].startswith('__'),
                 inspect.getmembers(object, lambda m: not inspect.ismethod(m)))   

    pprint.pprint(props)

 

Leave a Reply

Your email address will not be published. Required fields are marked *