> The only difference is that the `except` block implicitly unbinds the > variable when the block ends. >
Mmmm. Good to know, because that means that the semantics are the same, except... > > while (condition := expression) as flag: > ... > Ah! Are the parenthesis necessary there? Accepting "while/if as name" would remove much (but not all) of the > motivation for assignment expressions, while accepting assignment > expressions would make a dedicated while/if as name syntax unnecessary. > Most of the arguments in favor of ':=' have been through examples of generators in which the introduced name is used within, with the if/while case often forgotten. There can be cases in which combining both syntaxes is useful: x = None while compute(x := v for v in next_series_value(x)) as comp: ... x = comp > Like it or not, I expect that they will be seen as competing PEPs, not > independent ones. Finding a real-world example of something like the above synthetic example would be in favor of the orthogonality. -- Juancarlo *Añez*
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/