Re: Python newbie needs constructive suggestions

2006-07-24 Thread Chris Lambacher
On Sat, Jul 22, 2006 at 09:31:26PM +0200, Bruno Desthuilliers wrote: Lawrence D'Oliveiro a ?crit : In message [EMAIL PROTECTED], [EMAIL PROTECTED] wrote: b) give up on using an anonymous function and create a named successor function with def, This is what you have to do.

P.S. Re: Python newbie needs constructive suggestions

2006-07-24 Thread David G. Wonnacott
In response to my question, ``What is the idiomatically appropriate Python way to pass, as a function-type parameter, code that is most clearly written with a local variable?'', a number of you made very helpful suggestions, including the use of a default argument; if one wanted to give a name to

Re: P.S. Re: Python newbie needs constructive suggestions

2006-07-24 Thread Duncan Booth
David G. Wonnacott wrote: In response to my question, ``What is the idiomatically appropriate Python way to pass, as a function-type parameter, code that is most clearly written with a local variable?'', a number of you made very helpful suggestions, including the use of a default argument;

Re: Python newbie needs constructive suggestions

2006-07-22 Thread Peter Otten
[EMAIL PROTECTED] wrote: What is the idiomatically appropriate Python way to pass, as a function-type parameter, code that is most clearly written with a local variable? For example, map takes a function-type parameter: map(lambda x: x+1, [5, 17, 49.5]) What if, instead of just having

Re: Python newbie needs constructive suggestions

2006-07-22 Thread David G. Wonnacott
Many thanks to those of you who responded to my question about anonymous functions with local variables, filling me in on e) do something else clever and Pythonic that I don't know about yet? by pointing out that I can use (among other good things) lambda with default arguments. That should

Re: Python newbie needs constructive suggestions

2006-07-22 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : What is the idiomatically appropriate Python way to pass, as a function-type parameter, code that is most clearly written with a local variable? def functionWithLocal(andArg): localVar = 42 return andArg+localVar map(functionWithLocal, range(42)) For

Re: Python newbie needs constructive suggestions

2006-07-22 Thread Bruno Desthuilliers
Lawrence D'Oliveiro a écrit : In message [EMAIL PROTECTED], [EMAIL PROTECTED] wrote: b) give up on using an anonymous function and create a named successor function with def, This is what you have to do. Not necessarily. map(lambda x, one=1: one + x, range(42)) For some reason

Python newbie needs constructive suggestions

2006-07-21 Thread davew-python
What is the idiomatically appropriate Python way to pass, as a function-type parameter, code that is most clearly written with a local variable? For example, map takes a function-type parameter: map(lambda x: x+1, [5, 17, 49.5]) What if, instead of just having x+1, I want an expression that

Re: Python newbie needs constructive suggestions

2006-07-21 Thread faulkner
optional arguments. map(lambda x, one=1: x + one, ...) it is entirely possible, however, to implement let in python. def let(**kw): sys._getframe(2).f_locals.update(kw) def begin(*a): return a[-1] map(lambda x: begin(let(one=1), x+one), range(10)) i really should warn you, though, that

Re: Python newbie needs constructive suggestions

2006-07-21 Thread Justin Azoff
[EMAIL PROTECTED] wrote: What is the idiomatically appropriate Python way to pass, as a function-type parameter, code that is most clearly written with a local variable? For example, map takes a function-type parameter: map(lambda x: x+1, [5, 17, 49.5]) What if, instead of just having

Re: Python newbie needs constructive suggestions

2006-07-21 Thread Lawrence D'Oliveiro
In message [EMAIL PROTECTED], [EMAIL PROTECTED] wrote: b) give up on using an anonymous function and create a named successor function with def, This is what you have to do. For some reason mr van Rossum has this aversion to anonymous functions, and tries to cripple them as much as