Is hilarious mistake in Python design. Thanks @elfprince13.

```python
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 x
UnboundLocalError: local variable 'e' referenced before assignment
```

Thomas Dickerson  
@shriramk seems like a good thread to port over this doozy from Twitter. “here's possibly the worst Python scoping rule I've ever seen.” Try for ...

@radehi @elfprince13 none will be able to appreciate the code you've shared if you don't post it indented, so we can reproduce. I'd suggest you to use a website like pastebin for this. Python without indentation is impossible to read...

Follow

@mlliarm @elfprince13 Yes, is a bug in the Markdown support in my instance, am talking to the instance admin to try to figure out what we need to to do fix it. Thanks for the report 😁

Sign in to participate in the conversation
CleverLibre Social

CleverLibre Social is an inclusive social instance for open discussion, learning, and community.
All cultures welcome.
Hate speech and harassment strictly forbidden.