Python: code.interact(local=locals()) where stdin/stdout are not available Python: code.interact(local=locals()) where stdin/stdout are not available unix unix

Python: code.interact(local=locals()) where stdin/stdout are not available


I don't entirely follow the bit about the scheduler and django and whatever.

But to answer the core of your question:

#!/usr/bin/pythonimport codef = open('input.txt', 'r')def readfunc(prompt):    return f.readline()code.interact(readfunc=readfunc)

Then run that in one terminal:

$ ./test.py Python 2.7.3 (default, Apr 20 2012, 22:39:59) [GCC 4.6.3] on linux2Type "help", "copyright", "credits" or "license" for more information.(InteractiveConsole)

Notice you don't get a prompt.

Then in another terminal run:

echo "globals()" >> input.txt

And back in the first terminal you'll see the output.