Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jessamynsmith/1245520bbcd87477304891c68717c4da to your computer and use it in GitHub Desktop.
Save jessamynsmith/1245520bbcd87477304891c68717c4da to your computer and use it in GitHub Desktop.
>>> class MyClass:
... """ hello """
... attr1 = 'hello'
... attr2 = 23
...
... def method1(self):
... return self.attr1
...
... def __str__(self):
... return '{} {}'.format(attr1, attr2)
...
>>> my_obj = MyClass()
>>>
>>> for item in dir(my_obj):
... print(item, type(getattr(my_obj, item)))
...
('__doc__', <type 'str'>)
('__module__', <type 'str'>)
('__str__', <type 'instancemethod'>)
('attr1', <type 'str'>)
('attr2', <type 'int'>)
('method1', <type 'instancemethod'>)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment