How do I declare global vars or class vars in Python ?
Bruno Desthuilliers
bruno.42.desthuilliers at websiteburo.invalid
Fri Feb 20 12:38:27 EST 2009
Paddy O'Loughlin a écrit :
> 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
Check by yourself:
>>> import inspect
>>> inspect.isfunction(property)
False
>>> property()
<property object at 0xb7cbc144>
>>> dir(property)
['__class__', '__delattr__', '__delete__', '__doc__', '__get__',
'__getattribute__', '__hash__', '__init__', '__new__', '__reduce__',
'__reduce_ex__', '__repr__', '__set__', '__setattr__', '__str__',
'fdel', 'fget', 'fset']
>>>
>> 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"
One could say the same for each and any of the usual GoldenRules(tm).
More information about the Python-list
mailing list