How to print lambda result ?

Barak, Ron Ron.Barak at
Tue Jan 20 13:15:50 CET 2009


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:

1 event<function <lambda> at 0x00AFE670>
2 event<function <lambda> at 0x00AFE670>
3 event<function <lambda> at 0x00AFE6B0>

Reading the first results of didn't enlighten me.

Could you point to a URL which could set me on the right path to get the expected output ?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list