New PEP: Attribute Access Handlers
Christian Tanzer
tanzer at swing.co.at
Mon Jul 24 01:52:52 EDT 2000
Paul Prescod <paul at prescod.net> wrote:
> > In short, folding get/set/del into one function sucks. Besides, it
> > doesn't really help when you want to overload just get, but would like
> > to keep the set/del of the ancestor.
>
> That isn't true. You can chain gets to your ancestor's __attr_XXX__
> method if you want, but handle sets yourself or vice versa.
You can chain `__getattr__' to your ancestor's `__getattr__', too.
It just is a bit cumbersome.
IMHO, your proposal exchanges the handling of different attributes in
one function with the handling of different aspects of attribute
handling in one function
There are good reasons for the design of `__{g,s]etattr__' (it
is a general solution with a minimum of complexity and implementation
effort). I don't see any good reasons for mixing `get/set/del' of a
particular attribute into the same function (in particular, it is not
a general solution).
--
Christian Tanzer tanzer at swing.co.at
Glasauergasse 32 Tel: +43 1 876 62 36
A-1130 Vienna, Austria Fax: +43 1 877 66 92
More information about the Python-list
mailing list