Movatterモバイル変換
[0]ホーム
[Python-ideas] a bad feature in Python syntax
David Mertzmertz at gnosis.cx
Tue Feb 28 23:50:21 EST 2017
OK, I'm impressed!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 usedthat way "in the wild." I also never tried using `is` in a chained wayuntil just now.That said, there are at least three things perverse about the examplesbelow, and they should *definitely* never be used in real code.This is vaguely plausible (for variable defined in some more interestingway where the substring relation is not so obvious; say content read fromfiles):>>> a = "a">>> b = "abc">>> c = "abcde">>> a in b in cTrueOn Tue, Feb 28, 2017 at 6:56 PM, 语言破碎处 <mlet_it_bew at 126.com> wrote:> I'm bited once:> >>> '' in {} == False> False> >>> ('' in {}) == False> True>> # '' in {} == False ==>> ('' in {}) and ({} == False) ==>> False!>> I think only compare operations should be chained.>>>>>>>> _______________________________________________> Python-ideas mailing list>Python-ideas at python.org>https://mail.python.org/mailman/listinfo/python-ideas> Code of Conduct:http://python.org/psf/codeofconduct/>-- Keeping medicines from the bloodstreams of the sick; foodfrom the bellies of the hungry; books from the hands of theuneducated; technology from the underdeveloped; and puttingadvocates of freedom in prisons. Intellectual property isto the 21st century what the slave trade was to the 16th.-------------- next part --------------An HTML attachment was scrubbed...URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170228/a9de82d5/attachment.html>
More information about the Python-ideasmailing list
[8]ページ先頭