Re: [Tutor] function that returns a fn

2004-12-12 Thread Alan Gauld
> def getjlistrenderer(opname): > def listrender(): > # use opname, eg ops=getlist(opname) > # or set local fn variable > return renderer; > return listrender; > #?or f=listrender(); return f; > > Is it really as simple as this? Assuming your indentation is actually OK then yes, it is as easy as

Re: [Tutor] function that returns a fn

2004-12-11 Thread Kent Johnson
Yes, it really is that simple. :-) A common example is a function that makes a function which adds a constant to its argument: >>> def makeadder(n): ... def adder(x): ... return x + n ... return adder ... Make a function that adds 3 to its argument...note there is no special syntax for the

[Tutor] function that returns a fn

2004-12-11 Thread Nandan
I'm looking for resources to help me with a fn that returns a fn after binding one of its arguments (aka currying, like the bind1st of C++) Considering Python syntax is quite straightforward, this is my first try: def getjlistrenderer(opname): def listrender(): # use opnam