I often find myself in a situation like this:
>>> for line in infile.readlines():
... line = line.rtrim()
... line█ # ^^^^^ Oops, mistake!
At this point I want to start again (because I mixed up the "trim" from Java with the "strip" from Python). But I can't afford to let the loop run even one iteration, because it would mess with the file.
In this situation my typical way out is to type some illegal syntax, such as an exclamation mark:
>>> for line in infile.readlines():
... line = line.rtrim()
... line!
File "<stdin>", line 2
line!
^
SyntaxError: invalid syntax
>>> █
But that's a clumsy way of doing things, not pythonic at all. Isn't there some way to get the interpreter to forget the previous line of continuation that I typed in? That would also save me from retyping the whole thing again. Some control key combination? I can't find it.