f printing the lambda's object description.
> Bye,
> Ron.
>
>
> -Original Message-
> From: Tino Wildenhain [mailto:t...@wildenhain.de]
> Sent: Tuesday, January 20, 2009 14:22
> To: Barak, Ron
> Cc: python-list@python.org
> Subject: Re: How to print lamb
Tino Wildenhain wrote:
or in python <3.0:
(num,"s"*(num >1))
works fine in 3.0 too
>>> num=1
>>> (num,"s"*(num >1))
(1, '')
>>> num=2
>>> (num,"s"*(num >1))
(2, 's')
Of course, 0 events gets 's' also, so (num!=1) is the actual comparison
needed.
--
http://mail.python.org/mailman/listinfo/
Barak, Ron wrote:
Thanks Tino: your solutions without the lambda work nicely.
What I still don't understand is why the print does not execute the lambda and
prints the result, instead of printing the lambda's object description.
You did not call it.
--
http://mail.python.org/mailman/listinfo/
On Jan 20, 10:57 pm, Tim Northover wrote:
> Notice that there's no actual mention of num there, it's a function that
> takes one parameter. If that parameter happens to be num it does what
> you want, but there's no way for the interpreter to know what was
> intended.
Which is why my working exam
On Tue, 20 Jan 2009 09:26:14 -0500
"D'Arcy J.M. Cain" wrote:
> "%s" % lambda num: int(num)
Of course I meant...
"%s" % (lambda num: int(num))
--
D'Arcy J.M. Cain | Democracy is three wolves
http://www.druid.net/darcy/| and a sheep voting on
+1 416 425 1212 (DoD
On Tue, 20 Jan 2009 12:34:04 +
"Barak, Ron" wrote:
> Thanks Tino: your solutions without the lambda work nicely.
> What I still don't understand is why the print does not execute the lambda
> and prints the result, instead of printing the lambda's object description.
Because that's what you
alex23 writes:
> On Jan 20, 10:34 pm, "Barak, Ron" wrote:
for num in range(1, 4):
> ... string_ = "%d event%s" % (num, (lambda num: num > 1 and "s" or
> "")(num))
> ... print string_
The notation here suggests Ron is sligtly confused about what he
created. It was equivalent to
st
On Jan 20, 10:34 pm, "Barak, Ron" wrote:
> What I still don't understand is why the print does not
> execute the lambda and prints the result, instead of
> printing the lambda's object description.
The following two statements are identical:
>>> def f(x): return x
...
>>> f = lambda x: x
lambda
Ah, okay.
Now it's clear.
Thanks Tino.
Ron.
-Original Message-
From: Tino Wildenhain [mailto:t...@wildenhain.de]
Sent: Tuesday, January 20, 2009 14:45
To: Barak, Ron
Cc: python-list@python.org
Subject: Re: How to print lambda result ?
Barak, Ron wrote:
> Thanks Tino: your s
ak, Ron
Cc: python-list@python.org
Subject: Re: How to print lambda result ?
Hi,
Barak, Ron wrote:
Hi,
Wanting to print the correct plural after numbers, I did the following:
for num in range(1,4):
string_ = "%d event%s" % (num,lambda num: num > 1 and "s" or "&qu
[mailto:t...@wildenhain.de]
Sent: Tuesday, January 20, 2009 14:22
To: Barak, Ron
Cc: python-list@python.org
Subject: Re: How to print lambda result ?
Hi,
Barak, Ron wrote:
> Hi,
>
> Wanting to print the correct plural after numbers, I did the following:
>
> for num in range(1,4):
> string_
Hi,
Barak, Ron wrote:
Hi,
Wanting to print the correct plural after numbers, I did the following:
for num in range(1,4):
string_ = "%d event%s" % (num,lambda num: num > 1 and "s" or "")
print string_
However, instead of getting the expected output:
1 event
2 events
3 events
I get:
12 matches
Mail list logo