On 10/31/16, Guido van Rossum <gu...@python.org> wrote: > For "everything to the right" it would seem we have some freedom: e.g. if > we have "foo.bar?.baz(bletch)" is the call included? The answer is yes -- > the concept we're after here is named "trailer" in the Grammar file in the > source code ( > https://github.com/python/cpython/blob/master/Grammar/Grammar#L119), and > "primary" in the reference manual ( > https://docs.python.org/3/reference/expressions.html#primaries). This means > all attribute references ("x.y"), index/slice operations ("x[...]"), and > calls ("x(...)"). > > Note that in almost all cases the "?." operator will be used in an context > where there is no other operator of lower precedence before or after it -- > given the above meaning, it doesn't make a lot of sense to write "1 + x?.a" > because "1 + None" is always an error (and ditto for "x?.a + 1"). However > it still makes sense to assign such an expression to a variable or pass it > as an argument to a function. > > So you can ignore the preceding four paragraphs: just remember the > simplified rule (indented and in bold, depending on your email client) and > let your intuition do the rest. Maybe it can even be simplified more: > > > *The "?." operator splits the expression in two parts; the second part is > skipped if the first part is None.* > > Eventually this *will* become intuitive. The various constraints are all > naturally imposed by the grammar so you won't have to think about them > consciously. > > --Guido
If we skip function call then we also skip argument evaluation? def fnc(): print('I am here') None(fnc()) # behavior similar to this? None()[fnc()] # or to this? PL _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/