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 ...
Follow

@AccordionGuy the formatting in that post looks broken to you too, right? It's not only broken on my instance but in the actual post? Haven't yet figured out how to view the JSON-LD source.

@radehi Yes, but I just assumed it was one of those “formatting losses” that happens when you paste code into non-code places.

@AccordionGuy It showed up in a typewriter font, though? In theory, this version of Mastodon supports Markdown, but it's pretty broken.

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.