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 argume
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
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",
> >
> >
> > Thi
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))
>
[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
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 sui
[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 j
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
[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 jus
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
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 tha
11 matches
Mail list logo