On Thu, Jul 26, 2018 at 12:14 PM, David Mertz <me...@gnosis.cx> wrote: > So now at least TWO proponents of 505 cannot successfully translate a very > simple example taken almost directly from the PEP! > > Is that REALLY a good argument for it being helpful, and not being a bug > magnet?! >
Okay. I'll give you the ACTUAL transformation. food = spam?.eggs?.bacon can be rewritten as _tmp = spam if _tmp is not None: _tmp = _tmp.eggs if _tmp is not None: _tmp = _tmp.bacon food = _tmp Except for the fact that _tmp doesn't exist. Do you see why we accept "mostly-correct" transformations? It is *actually impossible* to perfectly represent short-circuiting semantics in Python! And before you go "well that proves my point, this suggestion is bad", let's apply the same test to a few other pieces of syntax. Rewrite the following statements without using the syntactic feature named in the comment: # 1) Decorators @deco def func(): ... # 2) "yield from" def chain(*iters): for iter in iters: yield from iter # 3) and the big one: generator expressions # yes, I'm deliberately using x multiple ways here def f(x): return x*x x = range(10) x = (f(x) for x in x if x % 2) I can pretty much guarantee you that you'll get these at least slightly wrong. Even experts will get genexps wrong. The most pedantic will put caveats on their equivalencies (like where I said "_tmp doesn't exist"), but chances are you won't even notice the discrepancies. So if that makes ?. bad, it makes decorators, yield from, and genexps far FAR worse. We'd better go back to Python 2.3, before they all existed. ChrisA _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/