Is hilarious mistake in Python design. Thanks @elfprince13.
def x(): e = None while e is None: try: print(input("? ")) except Exception as e: print(repr(e))x()
Result:
Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 3, in xUnboundLocalError: local variable 'e' referenced before assignment
@mlliarm @radehi happily my OP has a link to replit https://mumak.app/@elfprince13/109382319882403287
@mlliarm @elfprince13 The problem is not that a function has side effects.
@radehi @elfprince13 Okay, thanks
@elfprince13 @radehi Thanks. I can confirm that this happens in python 3.9.15 too, when I press CTRL+C to break the while loop. Anyhow, I wouldn't exactly blame python for creating a function with side effects.