MonkeeSage a écrit :
> On Nov 27, 3:20 am, Roy Smith <[EMAIL PROTECTED]> wrote:
>
>> If you want to have a little fun:
>>
>> class peverse:
>> def __call__(self):
>> raise AttributeError ("peverse instance has no __call__ method")
>>
>> x = peverse()
>> x()
print callable(x)
=> True
> That is "peverse", but still...
>
> from types import FunctionType
> type(x) == FunctionType # False
>
> And you can't (easily?) subclass FunctionType:
>
> Error when calling the metaclass bases
> type 'function' is not an acceptable base type
>
> ;)
You don't have to subclass function to define a callable type that
implements the descriptor protocol so it behaves just like a function in
the context of an attribute lookup.
--
http://mail.python.org/mailman/listinfo/python-list