on implementing a toy oop-system

Meredith Montgomery mmontgomery at levado.to
Thu Sep 29 12:37:15 EDT 2022


ram at zedat.fu-berlin.de (Stefan Ram) writes:

> Meredith Montgomery <mmontgomery at levado.to> writes:
>>The code below works, but you can see it's kinda ugly.  I wish I could
>>uncurry a procedure, but I don't think this is possible.  (Is it?)
>
> from functools import partial
> from operator import add
> add5 = partial( add, 5 )
> print( add5( 2 ))
> # might be dependent on implementation details of "functools":
> uncurried = add5.func
> print( uncurried( 14, 7 ))

It works on my system here.  Thank you so much for your help.  (I've
been learning a lot with you!)

>   However, to evaluate a method call such as "o.m( a, a1, ... )",
>   currying does not necessarily have to be used. One can as well 
>   determine the function to be used for "m" from the type of "o" 
>   and then call that function with arguments "o", "a", "a1", ... 

Was that your last approach?  I only glanced at it so far.  But I
remember seeing you describing an object and listing out which methods
were defined for it and then there was one procedure that would take the
role of invoking the methods (with the proper arguments).


More information about the Python-list mailing list