First page Back Continue Last page Overview Graphics

Attributs

>>> class Robot:

... pass

...

>>> x = Robot()

>>> y = Robot()

>>>

>>> x.name = "Marvin"

>>> x.build_year = "1979"

>>>

>>> y.name = "Caliban"

>>> y.build_year = "1993"

>>>

>>> print(x.name)

Marvin

>>> print(y.build_year)

1993

>>>

Warning:

Attributes are not usually used like that!

Internally, it looks like this:

>>> x.__dict__

{'name': 'Marvin', 'build_year': '1979'}

>>> y.__dict__

{'name': 'Caliban', 'build_year': '1993'}