This piece of code, file test.py,
if 1: print \"foo\" print \"bar\"
can be successfully executed with execfile(\"test.py\
execfile(\"test.py\
Continuation lines are needed when entering a multi-line construct. --Interactive mode, The Python Tutorial (v2) (v3)
So you need to enter:
if 1: print "foo" print "bar"
I've yet to find a suitable explanation as to why it's different to a non-interactive session, alas.