Special attributes

i1 is MyBase, i2 is MySub

Dictionary of user-defined attributes:
>>> i1.__dict__  # dictionary of user-defined attributes
{'i': 5, 'j': 7}
>>> i2.__dict__
{'i': 7, 'k': 9, 'j': 8}
Name of class, name of method:
>>> i2.__class__.__name__ # name of class
'MySub'
>>> i2.write.__name__     # name of method
'write'
List names of all methods and attributes:
>>> dir(i2)
['__doc__', '__init__', '__module__', 'i', 'j', 'k', 'write']

previousnexttable of contents