Why do descriptors (and thus properties) only work on attributes.
Steve Holden
steve at holdenweb.com
Tue Mar 1 13:23:10 EST 2005
Steven Bethard wrote:
> Steve Holden wrote:
>
>> Steven Bethard wrote:
>>
>>> Antoon Pardon wrote:
>>>
>>>> Can anyone explain why descriptors only work when they are an attribute
>>>> to an object or class. I think a lot of interesting things one can
>>>> do with descriptors would be just as interesting if the object stood
>>>> on itself instead of being an attribute to an other object.
>>>
>>>
>>> Not sure what "stood on itself" really means, but if you just want to
>>> be able to have module-level properties, you can do something like:
>>>
>> Think in non-English (stand outside yourself?) for a second,
>> rememberinf Antoon is Belgian (if you knew that):
>>
>> "on" => "by"
>>
>> "stood on itself" => "stood by itself"
>> => "standalone"
>>
>
> Sorry, I gathered that this meant "standalone". My problem was that I'm
> not sure what "standalone" means in the context of descriptors.
> Descriptors are invoked when dotted-attribute access is used. When
> exactly is he proposing "standalone" descriptors would be invoked?
>
Well, my *guess* was Antoon was referring to module attributes - names
that can be referenced without qualification using a "." operator.
Which, I suppose, is how you read it too. Sorry.
regards
stEvE
--
Meet the Python developers and your c.l.py favorites March 23-25
Come to PyCon DC 2005 http://www.pycon.org/
Steve Holden http://www.holdenweb.com/
More information about the Python-list
mailing list