currying (was: Re: A trivial question about print)

Jeremy Bowers newsfroups at jerf.org
Sun Apr 14 23:40:19 EDT 2002


Scott David Daniels wrote:
> I had kind of thought that the keyword args would take care of this.  
> Sure there are cases where this wouldn't be true, but  I'd hate to have 
> to read code that included ... curry([2, 3, 5], f, a1, a4, a6) ..., I'd have 
> the devil's own time determining which args were specified.

In the case I'm using it, it would still be a net gain. Basically, I 
have a whole list of function calls (to set up bindings), and I'm trying 
to make the calls as simple as possible.

(Why not use a data file? Well, I'm basically using the Python code 
itself as my data file. Python code understands the Python runtime data 
structures better then any data file interpreter I could possibly cook up.)

I was mostly curious if anybody had come up with a good way of 
expressing it; obviously, with your curry example in hand, creating the 
code to do what you want is the easy part. It's the specs that are hard.

> As to Alex's comment on the recipe -- of course he's right; I just hadn't seen 
> the possibility of curry by closure until nested scopes showed up after I
> had written curry.

BTW, thanks for that recipe. Not only have I found it useful code, but 
it taught me what currying *is*. I'd seen the pure functional kind, in 
lambda calculus style, but I found that hard to follow, so I tried 
http://www.google.com/search?hl=en&q=python+curry on a whim, and lo, 
there it was. (I think that's also how I found the whole recipes database.)




More information about the Python-list mailing list