This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eric.smith
Recipients eric.smith, mvyskocil
Date 2009-08-20.16:12:25
SpamBayes Score 0.0017748066
Marked as misclassified No
Message-id <1250784747.08.0.834744407946.issue6740@psf.upfronthosting.co.za>
In-reply-to
Content
This isn't the right forum to ask for help. You should try
comp.lang.python, where someone would be happy to explain this to you.

Having said that, here's the explanation:

This is not a bug.

Disregarding side effects, the expression:
a = b or c

is essentially the same as:
if b:
 a = b
else:
 a = c

So your code is:
if (lambda x : x == 'foo'):
 cond = (lambda x : x == 'foo')
else:
 cond = (lambda x : x == 'bar')

And since "(lambda x : x == 'foo')" evaluates to True (it's a lambda, so
it's not None), you're really saying:
cond = (lambda x : x == 'foo')

And your examples follow from that.

You can further verify this with your c1 and c2:
>>> cond = c1 or c2
>>> cond
<function <lambda> at 0x00B3EA30>
>>> cond is c1
True

So, you're just setting cond to the first of the 2 lambdas.
History
Date User Action Args
2009-08-20 16:12:27eric.smithsetrecipients: + eric.smith, mvyskocil
2009-08-20 16:12:27eric.smithsetmessageid: <1250784747.08.0.834744407946.issue6740@psf.upfronthosting.co.za>
2009-08-20 16:12:25eric.smithlinkissue6740 messages
2009-08-20 16:12:25eric.smithcreate