On Tue, Apr 6, 2021 at 3:46 AM Terry Reedy <tjre...@udel.edu> wrote: > *While 'a and not a' == False in logic, in Python it might raise > NameError. But that would still mean that it is never True, making > 'yield 0' still unreachable. >
And even just the lookup can have side effects, if your code is pathologically stupid. >>> class Wat(dict): ... def __missing__(self, key): ... global count ... count -= 1 ... return count ... >>> count = 2 >>> eval("print(a and not a)", Wat(print=print)) True So Python can't afford to treat this as dead code. ChrisA -- https://mail.python.org/mailman/listinfo/python-list