
Educators: Earn a free Gold upgrade by joining the PBwiki Back To School Challenge.
When you access an attribute of an instance but the instance does not have an attribute with the required name Python looks for the attribute in the class instead. So in the first case it would look as though each instance has a 'list' attribute, but it is the same value shared between all instances. In the second case each instance has its own 'list' attribute.
Q: Do I need getters/setters like in java?
A: NO! use `__get__` method on properties. Read the docs for the built in `property()` function. It's a nice mechanism to actually avoid all those getters and setters because you can turn "simple" attributes into "computed" attributes without changing the API of the objects.
Page Information
|
Wiki Information |
Recent PBwiki Blog Posts |