[Python-3000] callable()

Georg Brandl g.brandl at gmx.net
Thu Jul 27 10:41:07 CEST 2006


Greg Ewing wrote:
> Guido van Rossum wrote:
> 
>> I'd be happy to extend the convention to all such attributes --
>> setting it to None to mean that the subclass doesn't want to provide
>> it. That's clean, can't possibly be interpreted to mean anything else,
>> and doesn't require you to actually call the attribute.
> 
> Although unless there's some special casing for it in the
> interpreter, attempting to use such an attribute will
> give a somewhat confusing error message -- something
> like "Object of type NoneType is not callable" instead
> of "Object of type <YourClass> has no __xxx__ attribute".

Only if the slot isn't automatically set to NULL iff the corresponding
attribute is set to None. (The "no __xxx__ attribute" error message
doesn't make sense then either, but I think the real messages are more
in the style of "xxx is not hashable").

Georg



More information about the Python-3000 mailing list