How to replace an instance method?

2QdxY4RzWzUUiLuE at potatochowder.com 2QdxY4RzWzUUiLuE at potatochowder.com
Mon Sep 19 15:19:01 EDT 2022


On 2022-09-18 at 09:11:28 +0000,
Stefan Ram <ram at zedat.fu-berlin.de> wrote:

> ram at zedat.fu-berlin.de (Stefan Ram) writes (abbreviated):
> >types.MethodType( function, instance )
> >functools.partial( function, instance )
> >new_method.__get__( instance )
> 
>   I wonder which of these three possibilities expresses
>   the idea of creating a new method from a function and
>   an instance most clearly.

The first one.  And only the first one.

The second one requires too much inside knowledge of Python to make the
leap from currying to instance method.

The third one doesn't even mention the function.  Also, in Python, if
I'm applying dunder methods directly (it's okay to write them), then I'm
doing something wrong.


More information about the Python-list mailing list