Difference between 'function' and 'method'

castironpi at gmail.com castironpi at gmail.com
Wed Mar 5 04:53:52 CET 2008


On Mar 4, 9:01 pm, "Gabriel Genellina" <gagsl-... at yahoo.com.ar> wrote:
> En Wed, 05 Mar 2008 00:30:26 -0200, <castiro... at gmail.com> escribió:
>
> > On Mar 4, 8:11 pm, "Gabriel Genellina" <gagsl-... at yahoo.com.ar> wrote:
> >> En Tue, 04 Mar 2008 16:45:40 -0200, <castiro... at gmail.com> escribió:
>
> >> >> 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
>
> >> Use delegation instead of inheritance. This class is almost  
> >> indistinguishable from a true function (when used as a method):
>
> [... long interactive example ...]
>
> > I actually don't believe you-- bar is not bound to an instance when P
> > is initialized... er, instantiated.  However, the evidence indicates
> > my belief mechanism is faulty... and rather conclusively at that.
> > <moves to acquire new evidence>  If P calls __get__( you ), is p a
> > gotcha?
>
> I didn't cheat, that was an actual Python interactive session. So you'll  
> have to formulate a new theory taking into account the new facts... or  
> read how the descriptor protocol workshttp://www.python.org/doc/newstyle/
> I don't understand your last sentence.
>
> --
> Gabriel Genellina

<joke>
If P gets, p gotcha.
</joke>

gotcha= partial( get, you ).  bor hor hor.  Yes... regarding the
descriptoring, just make it official!  UserFunctionType or smg.



More information about the Python-list mailing list