Thank you for the suggestions and code! > import code > > SCRIPT = [line.rstrip() for line in open("myscript.py")] > > script = "" > prompt = ">>>" > > for line in SCRIPT: > print prompt, line > script = script + line + "\n" > co = code.compile_command(script, "<stdin>", "exec") > if co: > # got a complete statement. execute it! > exec co > script = "" > prompt = ">>>" > else: > prompt = "..." >
This one fails at function definition. def fun(): a=1 b=2 <--- not included. Still trying other methods. Bo -- http://mail.python.org/mailman/listinfo/python-list