On Thu, 14 Nov 2019 at 16:42, Random832 <random832@fastmail.com> wrote:
So, uh... what if we didn't need backslashes for statements that begin with a keyword and end with a colon? There's no syntactic ambiguity there, right? Honestly, adding this would make me less annoyed with the error I get when I forget the colon, since it'd actually have a purpose other than grit on the screen.
Not sure about ambiguity, but it would require a much more powerful parser than Python currently has (which only looks ahead one token). Guido is experimenting with PEG parsers, so maybe it will be a possibility in the future, but right now the current parser can't handle it (yes, there are hacks for some special constructs already, but this would need *arbitrary* lookahead - you could have many lines between the with and the colon). Also, I suspect it would really screw up error reporting: with open(fname1) as f1, open(fname2) as f2, open(fname3) as f3, open(fname4) as f4, # Whoops, comma instead of colon print(hello) import xxx as bar if some_var > 10: return Computer parsers are far dumber than human brains, and if I looked at that without having written it, *I'd* have trouble working out what was wrong, so the poor computer has no chance! Paul