This piece of code, file test.py,
if 1:
print \"foo\"
print \"bar\"
can be successfully executed with execfile(\"test.py\
I don't know any trick for the standard command prompt, but I can suggest you a more advanced interpreter like IPython that has a special syntax for multi-line paste:
In [1]: %cpaste
Pasting code; enter '--' alone on the line to stop.
:for c in range(3):
: print c
:
:--
0
1
2
Another option is the bpython interpreter that has an automatic paste mode (if you are typing too fast to be an human):
>>> for c in range(3):
... print c
...
0
1
2
>>>
Rewind Save Pastebin Pager Show Source