I would like to have a logger function to print out recursively all members regardless of type. For example:
magic_print(5) #5
magic_print([1,2,'abc']) # 1, 2, 'abc'
class C(object):
def __init__(self):
self.x = 5
c = C()
magic_print(c) #c.x = 5
Currently, if I use plain print, I get the following:
print c #<__main__.C object at 0x10c3e0fd0>
Is there such a function built in? Or do I need to write it? (Using Python 2.7)
edit - Please note, I do not ask how to print an object (someone thought I duplicated a fairly easy question) - I want to be able to "inspect" the object regardless of type. the str and repr of c (in the example) both don't show the inner members/state.
Thanks!