[EMAIL PROTECTED] wrote:
When I look at how classes are set up in other languages (e.g. C++), I
often observe the following patterns:
1) for each data member, the class will have an accessor member
function (a Get<whatever> function)
2) for each data member, the class will have a mutator member function
(a Set<whatver> function)
3) data members are never referenced directly; they are always
referenced with the accessor and mutator functions
My questions are:
a) Are the three things above considered pythonic?
No
b) What are the tradeoffs of using getattr() and setattr() rather than
creating accessor and mutator functions for each data member?
Use property descriptors instead:
http://www.python.org/2.2.1/descrintro.html#property
http://users.rcn.com/python/download/Descriptor.htm#properties
Michael
--
http://mail.python.org/mailman/listinfo/python-list