[Python-Dev] Definining properties - a use case for class decorators?

Aahz aahz at pythoncraft.com
Tue Oct 18 17:49:00 CEST 2005


On Tue, Oct 18, 2005, Barry Warsaw wrote:
>
> You could of course "just" do the wrapping in property().  I put that in
> quotes because you'd have the problem of knowing when to wrap and when
> not to, but there would be ways to solve that.  But I won't belabor the
> point any longer, except to ask what happens when you typo one of those
> strings?  What kind of exception do you get and when do you get it?

AttributeError, just like this:

    class C: pass
    C().foo()

Last night I was thinking that maybe TypeError would be better, but
AttributeError is going to be what the internal machinery raises, and I
decided there was no point trying to translate it.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"If you think it's expensive to hire a professional to do the job, wait
until you hire an amateur."  --Red Adair


More information about the Python-Dev mailing list