classes (was Re: Same again please for OOP)

Moshe Zadka moshez at zadka.site.co.il
Tue Dec 26 02:04:27 EST 2000


On Mon, 25 Dec 2000, "Emile van Sebille" <emile at fenx.com> wrote:

> Just to throw in my $.02.
> 
> If not for __getattr__ and __setattr__, I probably wouldn't
> have continued with Python.  I'm not sure I would have found
> anything better, so I may have come back anyway, but these
> two automagic functions allowed me to write a proof of
> concept model in about two days, when in other environments
> I had nothing worthwhile after two weeks.

To clarify my position: I don't think the __getattr__/__setattr__
functionality is not needed, and indeed, in several cases, this is
a very powerful feature. My only gripe is that this power is given
in a very non-Pythonic way: it's way too easy to shoot one's self
in the foot with it.

What if, instead, you'd have a way to mark methods as as "auto-called"
methods: IOW, a method which is automatically called as soon as an
attribute is get/set/deleted. This would solve 80% of the problem,
living raw __getattr__ usage to arcane problems.

-- 
Moshe Zadka <sig at zadka.site.co.il>
This is a signature anti-virus. 
Please stop the spread of signature viruses!




More information about the Python-list mailing list