> it's actually hard to represent Python code in regular HTML
It is not hard. Just use the right tag. You want the <pre> tag here. Here, fixed it for you:
def foo(flag):
if flag:
print("this is indented")
print("is this?")
For example, here is some Python code typed correctly in the comment box but rendered without the code formatting support (using a | at beginning of line to prevent the code formatting to kick in):
|def foo(flag):
| if flag:
| print("this is indented")
| print("is this?")
If you check the HTML, it looks like this: