> assert log(flag := complex_expression) or flag > > That doesn't seem very useful: for that assert to fail, `flag` would have > to be falsey, and if falsey, then surely the log of it is not helpful?
Unless complex_expression produces an object that has useful information when Falsey. But it’s a toy example that I think makes the point well that there may be a good use of := in an assert. In fact, it’s my impression (and we’ll see how it works out) that the walrus operator is best used in a “local” manner such as this— if the assignment is important later in the code, it may be better to stick with regular assignment anyway. -CHB > > -- > ~Ethan~ > _______________________________________________ > Python-ideas mailing list -- [email protected] > To unsubscribe send an email to [email protected] > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.org/archives/list/[email protected]/message/N5BMTKG6KHNRDFVCISQ2YFFXK33YR7I2/ > Code of Conduct: http://python.org/psf/codeofconduct/ > -- Christopher Barker, PhD Python Language Consulting - Teaching - Scientific Software Development - Desktop GUI and Web Development - wxPython, numpy, scipy, Cython
_______________________________________________ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/[email protected]/message/L4SQBJ6FVQCZRZZOHCS2KZWRFYE67T64/ Code of Conduct: http://python.org/psf/codeofconduct/
