[Python-Dev] PEP 318 - generality of list;
restrictions on elements
Aahz
aahz at pythoncraft.com
Wed Mar 10 21:34:32 EST 2004
On Wed, Mar 10, 2004, Fred L. Drake, Jr. wrote:
> On Wednesday 10 March 2004 08:43 pm, Aahz wrote:
>>
>> That's why I said "kind of callable"; from the user's POV, they act like
>> callables because you invoke them with call syntax, just like methods.
>
> My first reaction to this was "Since when??!?"
>
> If the only descriptors you're thinking about are things that return
> callables from the __get__() method, it makes sense that you've made
> this mistake. What needs to be considered though is that not all
> descriptors provide callable results. Remember that "property" is a
> descriptor type; instances of property are not normally callable.
"They" was referring to Greg's mention of classmethods and staticmethods.
Despite the example given of the colormap, it's still not clear to me
what the use case is for a decorator returning an object that doesn't
get used as a callable, particularly when weighed against the
disadvantages.
There's a lot of ambiguity floating around with the advent of properties.
Although properties don't use call syntax, IMO they certainly have call
semantics because the get or set descriptor gets called by the attribute
machinery under the covers. (I just checked -- it's legal to define a
property that uses string objects in the property() call, but you'll get
a TypeError when you try to access the attribute.) I think that
properties as a specific case are sufficiently useful to warrant the
blurring, but I'd rather not see that blurring generalized through
Python.
--
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
"Do not taunt happy fun for loops. Do not change lists you are looping over."
--Remco Gerlich, comp.lang.python
More information about the Python-Dev
mailing list