problem with curring in python

Terry Reedy tjreedy at udel.edu
Tue Oct 22 13:18:00 EDT 2019


On 10/22/2019 6:15 AM, Antoon Pardon wrote:
> On 22/10/19 12:02, Terry Reedy wrote:
>> On 10/22/2019 4:58 AM, Antoon Pardon wrote:
>>> Using python 3.5
>>>
>>> I have been experimenting with curried functions. A bit like in Haskell.
>>> So I can write the following function:
>>>
>>> def sum4(a, b, c, d):
>>>       return a + b + c + d
>>>
>>> summing = curry(sum4)
>>>
>>> print summing(1)(2)(3)(4) # this prints 10.
>>>
>>> The problem is I need the signature of the original function in order to
>>> know when to finally call the function and return the actual result.
>>> However buildin functions don't have a
>>
>> I believe most do.
> 
> Well I may have jumped to my conclusion, but those in operator don't seem
> to have a signature.
> 
>>>> inspect.signature(operator.mul)

By default, 'python', to me, refers to the current, most recent version, 
now 3.8. As Peter Otten said, this now has a proper signature, added 
with Argument Clinic.

I read 'buildin functions' as 'builtins functions', functions in the 
builtins module, bound to '__builtins__' in the main module.  Of the 69 
functions listed in https://docs.python.org/3/library/functions.html,
43 have a proper signature (non-None __text_signature__) and 26 do not.
A majority if not 'most'.

For the alternate reading of 'built-in functions' (in the stdlib), the 
ratio of conversions to a proper signature may be lower.  The process is 
on-going.

-- 
Terry Jan Reedy





More information about the Python-list mailing list