[Python-Dev] Computed-attributes
Donald Beaudry
Donald Beaudry <donb@init.com>
Thu, 20 Jul 2000 15:48:45 -0400
Paul Prescod <paul@prescod.net> wrote,
> Donald Beaudry wrote:
> > The cost is some additional burden on the writer of the __attr_XXX
> > method (and some magic to distinguish the del case).
>
> Don't follow that. Why not just have "get"/"set"/"del" opcodes?
Sorry about that... it was an editing problem. At first I was going
to propose that the __attr_XXX method take just one optional argument:
the set value. If it was there do a set, if not do a get. The
problem was how to do the del (magic?). Then I had the bright idea of
using the op parameter but never removed my "magic" comment.
The "additional burden" I was refering to was that of writing a method
which must first decide what to do. Personally, I call this a feature
since it forces all maintenance of a given attribute into a single
place. Others might argue that the code in a single purpose setter,
getter, or deller would read better.
--
Donald Beaudry Ab Initio Software Corp.
201 Spring Street
donb@init.com Lexington, MA 02421
...So much code, so little time...