Slash in indentation

    \
def main:
    if True:
        print("hello world")

this code produces indentation error: unexpected indent, which seems unintutive. is this expected behavior, if not a warning may be issued in future versions.

suggestion: the empty line ending with slash newline may be discarded for the purpose of calculating indentations.

Interesting that you don’t get an error ( SyntaxError: expected '(' ) for missing the parentheses after the word main.

Like this:

def main():
    if True:
        print("hello world")

That should happen because the \ is before that, so the error about that gets raised first.

2 Likes

The \ means a line continuation so that the indentation ahead of the \ is prepended to the def main line causing the indentation error. As @onePythonUser pointed out you are missing the parentheses after main - it should be def main():

The indentation error is correct. The code is logically identical to def main... with an erroneous indent.