[Python-Dev] functools.compose to chain functions together

Stefan Behnel stefan_ml at behnel.de
Mon Aug 17 11:14:05 CEST 2009


Antoine Pitrou wrote:
> Raymond Hettinger <python <at> rcn.com> writes:
>> IMO, its only virtue is that people coming from functional languages
>> are used to having compose.  Otherwise, it's a YAGNI.
> 
> Then I wonder how partial() ended up in the stdlib. It seems hardly more
> useful than compose().

I would certainly consider it more useful, but that aside, it's also a lot
simpler to understand and use than the proposed compose() function. I think
the main difference is that compose() requires functional/math skills to be
used and read correctly (and might still be surprising in some corner
cases), whereas partial() only requires you to understand how to set a
function argument. Totally different level of mental complexity, IMHO.

Stefan



More information about the Python-Dev mailing list