"Fredrik Lundh" <fr*****@python ware.com> writes:
I want to sum up some ideas in the thread:
1) setters and getters are not mandatory.
2) The usual way in Python is the direct access
[=] ... b.width # is get
b.width = # is set
del b.width # is del
3) If when setting some attribute there is necesary to have side
effects, it can be achive defining __setattr__ and doing the right
thing depend on the attribute. (It is possible to raise an
exception when the attribute is not in a list/dictionary of usable
attributes, to prevent typos and such kind of errors)
4) __getattr__ can be defined to deal with undefined attributes. For
example it can handle in different way the attributes in a list of
permited attributes (see point 3)
5) attributes that are computed in the fly, can be get like normal
attributes using "property" (property is new in 2.3 or 2.2?)
6) attributes and methods that are no part of the user interface are
named with and _ in the front. (This is a convention)
Are those ideas correct? We can continue with the discussion!!
Zunbeltz
--
Remove XXX from email:
zu******@wm.lc. ehu.esXXX