First page Back Continue Last page Overview Graphics

Attributes and Class Names

>>> class Robot(object):

... pass

...

>>> x = Robot()

>>> Robot.brand = "Kuka"

>>> x.brand

'Kuka'

>>> x.brand = "Thales"

>>> Robot.brand

'Kuka'

>>> y = Robot()

>>> y.brand

'Kuka'

>>> Robot.brand = "Thales"

>>> y.brand

'Thales'

>>> x.brand

'Thales'

>>> x.__dict__

{'brand': 'Thales'}

>>> y.__dict__

{}

>>> Robot.__dict__

mappingproxy({'__module__': '__main__', '__weakref__': <attribute '__weakref__' of 'Robot' objects>, '__doc__': None, '__dict__': <attribute '__dict__' of 'Robot' objects>, 'brand': 'Thales'})