Created
August 30, 2013 05:38
-
-
Save tokibito/6386611 to your computer and use it in GitHub Desktop.
pprint and vars
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> class MyClass(object): | |
... def __init__(self, x, y): | |
... self.x = x | |
... self.y = y | |
... self.foo = {'foo': {'bar': 'hoge'}} | |
... self.ref = self | |
... | |
>>> obj = MyClass(10, 20) | |
>>> vars(obj) | |
{'y': 20, 'x': 10, 'foo': {'foo': {'bar': 'hoge'}}, 'ref': <__main__.MyClass object at 0x025E46D0>} | |
>>> import pprint | |
>>> pprint.pprint(vars(obj)) | |
{'foo': {'foo': {'bar': 'hoge'}}, | |
'ref': <__main__.MyClass object at 0x025E46D0>, | |
'x': 10, | |
'y': 20} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment