I have not personally ever used the walrus operator, and I don't think I've even seen it used in the wild, either. That's not a commentary on how useful it is, but that it takes time for changes like this (that can't be back-ported) to get much real world use. So no, I don't think it's time to relax the restrictions -- for the same reason the restrictions were there in the first place. - CHB On Sun, May 8, 2022 at 9:40 AM Steven D'Aprano <steve@pearwood.info> wrote:
On Sun, May 08, 2022 at 04:00:47PM +0100, Rob Cliffe wrote:
Yes, I know unrestricted use of the walrus can lead to obfuscated code (and some of Steven's examples below might be cited as instances 😁).
They're intended as the simplest, least obfuscatory examples of using the walrus operator that is not pointless. That is, an example of the walrus as a sub-expression embedded inside another expression.
If you think my examples are obfuscated, then that is an argument in favour of keeping the status quo.
I could have given an example like this:
((a, b) := [1, 2])
but there is no good reason to use the walrus operator there, it is not a sub-expression, and it Just Works if you use the assignment statement instead.
-- Steve _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-leave@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/S7MU7O... Code of Conduct: http://python.org/psf/codeofconduct/
-- Christopher Barker, PhD (Chris) Python Language Consulting - Teaching - Scientific Software Development - Desktop GUI and Web Development - wxPython, numpy, scipy, Cython