[Python-Dev] Computed-attributes
Paul Prescod
paul@prescod.net
Thu, 20 Jul 2000 12:52:28 -0500
Gordon McMillan wrote:
>
> ...
> Then:
>
> class A:
> def __init__(self):
> self.y = <something>
> class B(A):
> def __set_y__(self, value):
> ...
> def __init__(self):
> A.__init__(self)
>
> means that the hook in B will be invoked when A.__init__
> runs. I wonder what "gotchas" lie in wait ;-).
Python is full of these gotchas. (__setattr__ has the same problem, for
example). It's amazing that anything ever works. :) For any lurkers: my
tongue is firmly in my cheek!
> [I also note that there are quite a few Python developers who
> want their users to say "x = obj.getx()", but want Python to
> create the accessor method "getx(self)" (if they haven't written
> one) and outlaw "x = obj.x". I have no sympathy for them, but
> they exist.]
Java-heads.
--
Paul Prescod - Not encumbered by corporate consensus
"Hardly anything more unwelcome can befall a scientific writer than
having the foundations of his edifice shaken after the work is
finished. I have been placed in this position by a letter from
Mr. Bertrand Russell..."
- Frege, Appendix of Basic Laws of Arithmetic (of Russell's Paradox)