<div dir="ltr">OK, I'm impressed! <div><br></div><div>I've written about and taught Python for almost 20 years. I never realized `in` was a chained comparison. I'm pretty sure I've never seen it used that way "in the wild." I also never tried using `is` in a chained way until just now.<br><div class="gmail_extra"><br></div><div class="gmail_extra">That said, there are at least three things perverse about the examples below, and they should *definitely* never be used in real code.</div><div class="gmail_extra"><br></div><div class="gmail_extra">This is vaguely plausible (for variable defined in some more interesting way where the substring relation is not so obvious; say content read from files):</div><div class="gmail_extra"><br></div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div class="gmail_extra"><div class="gmail_extra"><font face="monospace, monospace">>>> a = "a"</font></div></div></div><div><div class="gmail_extra"><div class="gmail_extra"><font face="monospace, monospace">>>> b = "abc"</font></div></div></div><div><div class="gmail_extra"><div class="gmail_extra"><font face="monospace, monospace">>>> c = "abcde"</font></div></div></div><div><div class="gmail_extra"><div class="gmail_extra"><font face="monospace, monospace">>>> a in b in c</font></div></div></div><div><div class="gmail_extra"><div class="gmail_extra"><font face="monospace, monospace">True</font></div></div></div></blockquote><div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Feb 28, 2017 at 6:56 PM, 语言破碎处 <span dir="ltr"><<a href="mailto:mlet_it_bew@126.com" target="_blank">mlet_it_bew@126.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="line-height:1.7;color:rgb(0,0,0);font-size:14px;font-family:arial">I'm bited once:<br> >>> '' in {} == False<br> False<br> >>> ('' in {}) == False<br> True<br><br> # '' in {} == False ==>> ('' in {}) and ({} == False) ==>> False!<br><br>I think only compare operations should be chained.<br><br><br><span id="gmail-m_-136956998814883338transmark" style="display:none;width:0px;height:0px"></span><br></div><br><br><span title="neteasefooter"><p> </p></span><br>______________________________<wbr>_________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/<wbr>codeofconduct/</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Keeping medicines from the bloodstreams of the sick; food <br>from the bellies of the hungry; books from the hands of the <br>uneducated; technology from the underdeveloped; and putting <br>advocates of freedom in prisons. Intellectual property is<br>to the 21st century what the slave trade was to the 16th.<br></div>
</div></div></div>