properties and get/set methods

Terry Reedy tjreedy at udel.edu
Sun Apr 6 12:27:47 EDT 2003


"Mike C. Fletcher" <mcfletch at rogers.com> wrote in message
news:mailman.1049604615.22077.python-list at python.org...
> In these cases, you're using properties to simplify the modelling of
> domain objects, or to provide some *generic* functionality over and
> above a regular value get/set.  You don't want to have to specify
that
> functionality for every property, you just want to say "this is one
of
> _those_ properties".  The code bloat (not to mention mindless
> duplication of code) when you get up to 15 or 20 properties for an
> object would be ridiculous.

Perhaps what you want are __get/setattr__ methods that check if the
attribute is one of 'those-properties' (in a set/dict lookup) and if
so, does the generically different thing.  My impression is that
properties are meant for doing attribute specific customization
without loading up/slowing down __get/setattr__ with a long list of
if/elif blocks.

Terry






More information about the Python-list mailing list