Background ("PEP 572 and decision-making in Python"):
replies(2):
yeah, if you code on 20 years old compilers with no warnings. GCC 4.1 warns about this (with -Wall) and Clang 3.4 warns about this too, without any warning flag.
(Assume for the sake of argument it’s some more reasonable example like "if (x = re_match(foo, bar)) {...}")
if (auto x = re_match(foo, bar); x.has_value()) {
(or x.ok() or whatever the name is of the method that tells you the validity of x)