Michael Torrie <[EMAIL PROTECTED]> wrote:
> poof65 wrote:
>> An idea, i don't know if it will work in your case.
>>
>> for x in xrange(10):
>> funcs.append(lambda p,z=x: testfunc(z+2,p))
>
> Good idea. I will try it. I also figured out a way to architecture my
> program differently to avoid
"Michael Torrie" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
|I need to use a lambda expression
Lambda expressions are a convenience, not a necessity. When having a
problem, it sometimes helps to revert to the unabbreviated def statement.
tjr
--
http://mail.python.org/mail
On Mar 1, 8:50 pm, Michael Torrie <[EMAIL PROTECTED]> wrote:
> I need to use a lambda expression to bind some extra contextual data
> (should be constant after it's computed) to a call to a function. I had
> originally thought I could use something like this demo (but useless) code:
>
> funcs=[]
>
poof65 wrote:
> An idea, i don't know if it will work in your case.
>
> for x in xrange(10):
> funcs.append(lambda p,z=x: testfunc(z+2,p))
Good idea. I will try it. I also figured out a way to architecture my
program differently to avoid this problem. But this idiom might be
handy in certain
An idea, i don't know if it will work in your case.
for x in xrange(10):
funcs.append(lambda p,z=x: testfunc(z+2,p))
On Sun, Mar 2, 2008 at 3:50 AM, Michael Torrie <[EMAIL PROTECTED]> wrote:
> I need to use a lambda expression to bind some extra contextual data
> (should be constant after it's
I need to use a lambda expression to bind some extra contextual data
(should be constant after it's computed) to a call to a function. I had
originally thought I could use something like this demo (but useless) code:
funcs=[]
def testfunc(a,b):
print "%d, %d" % (a,b)
for x in xrange(10):
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote in
news:[EMAIL PROTECTED]:
>
> Shi Mu wrote:
>> what does the following code mean? It is said to be used in the
>> calculation of the overlaid area size between two polygons.
>> map(lambda x:b.setdefault(x,[]),a)
>
> The equivalent of :
>
> def oh_
Shi Mu wrote:
> what does the following code mean? It is said to be used in the
> calculation of the overlaid area size between two polygons.
> map(lambda x:b.setdefault(x,[]),a)
>
> Thanks!
Assuming b is a dict, it is roughly equivalent to the following (except
that the variables beginning wit
Shi Mu wrote:
> what does the following code mean? It is said to be used in the
> calculation of the overlaid area size between two polygons.
> map(lambda x:b.setdefault(x,[]),a)
The equivalent of :
def oh_my_yet_another_function_name_why_not_use_lambda(x):
b.setdefault(x,[])
map(oh_my_yet_an
what does the following code mean? It is said to be used in the
calculation of the overlaid area size between two polygons.
map(lambda x:b.setdefault(x,[]),a)
Thanks!
--
http://mail.python.org/mailman/listinfo/python-list
10 matches
Mail list logo