How do I declare global vars or class vars in Python ?

Paddy O'Loughlin patrick.oloughlin at gmail.com
Fri Feb 20 12:04:23 EST 2009


2009/2/20 Bruno Desthuilliers <bruno.42.desthuilliers at websiteburo.invalid>:
>> Interesting. Why shouldn't you?
>> I haven't used the property() function
>
> s/function/object/

Nice try, but what I wrote was what I intended to say:
http://docs.python.org/library/functions.html#property

For all I know I could have used property objects several times in modules :)

> The case is that the whole point of using a computed attribute is to perform
> some computation on the value. IOW, except for a couple corner cases, only
> the accessors should directly access the implementation(s) attributes(s).
>
> And of course, like for any other GoldenRule(tm), it's not meant to be
> blindly followed. It's just that most of the times, going thru the accessors
> is really what you want - even from within the class code.

Hmm, it doesn't seem to me like it's much of a big deal, for it to
described as anything like a "GoldenRule" or to advise against its
overuse.
You use it when its appropriate and don't use it when you it's not,
like any other feature.

Paddy


-- 
"Ray, when someone asks you if you're a god, you say YES!"



More information about the Python-list mailing list