Difference between 'function' and 'method'

castironpi at gmail.com castironpi at gmail.com
Tue Mar 4 13:45:40 EST 2008


> > So, to answer your question: what you are decorating are functions, not
> > methods.
>
> Can you overload -type-'s decision of what to 'bind'?... whenever it
> is it makes it.

>>> from types import FunctionType, MethodType
>>> class A( FunctionType ): pass
...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: type 'function' is not an acceptable base type
>>> class A( MethodType ): pass
...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: type 'method' is not an acceptable base type

Unacceptable.



More information about the Python-list mailing list