Hi,<div><br></div><div>The "or" expression will return the first element that evaluates to True, or the last element if they all evaluate to False.  Positive integers evaluate to True.  None evaluates to False.</div>
<div><br></div><div>See:  <a href="http://docs.python.org/library/stdtypes.html#truth-value-testing">http://docs.python.org/library/stdtypes.html#truth-value-testing</a></div><div><br></div><div><a href="http://docs.python.org/library/stdtypes.html#truth-value-testing"></a>-eric<br>
<br><div class="gmail_quote">2011/4/6 Íéêüëáïò Êïýñáò <span dir="ltr"><<a href="mailto:nikos.kouras@gmail.com">nikos.kouras@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
>>> mail = None<br>
>>> mail = mail or 7<br>
>>> mail<br>
7<br>
<br>
>>> mail = None<br>
>>> mail = 7 or mail<br>
>>> mail<br>
7<br>
<br>
Here no matter the order iam writing the comparison it always return<br>
the number.<br>
<br>
why not the same here?<br>
<div class="im"><br>
>>> mail = None<br>
>>> mail = mail or ''<br>
>>> mail<br>
''<br>
<br>
</div>>>> mail = None<br>
>>> mail = '' or mail<br>
>>> mail<br>
>>><br>
<br>
Why the or operator behaves differently with numbers than from<br>
strings?<br>
<br>
Please explain to me how it parses it with words.<br>
<br>
Thank you.<br>
<div><div></div><div class="h5">--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</div></div></blockquote></div><br></div>