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
```
@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.
@ambihelical @freemo By "plain text mode" mean "not Markdown mode"? I don't have a problem with prepending four spaces to each line (that's standard Markdown, fenced code blocks are a common extension) but that didn't keep the buggy implementation from eating my newlines.
Let's try four spaces:
def main():
pass
@ambihelical @freemo See, there was a newline after the colon, but got eaten. Inspecting the page DOM shows that there's a `<pre>` and a somewhat unnecessary but harmless `<code>` inside it, but the actual text node in the DOM has no newline in it.
@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.
@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...
@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 😁
@mlliarm @radehi happily my OP has a link to replit https://mumak.app/@elfprince13/109382319882403287
@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.
@mlliarm @elfprince13 The problem is not that a function has side effects.
@radehi @elfprince13 Okay, thanks
@freemo why is the formatting in this post broken? The pseudo-Markdown implementation seems to be eating all the newlines. How does that happen and how can we fix it?