[Tutor] from command prompt use interactive python and running script together

Steven D'Aprano steve at pearwood.info
Sat Feb 22 02:34:39 CET 2014


On Fri, Feb 21, 2014 at 09:20:15AM -0500, Gabriele Brambilla wrote:
> Hi,
> 
> Is possible on python to running scripts from the command prompt (I'm using
> python on windows) and in the end saving all the variables and continue the
> analysis in the interactive mode? (the one that you activate typing python
> in the command prompt?)

The best way to do this is to use a Python shell that supports it. 
ipython is an advanced, powerful shell that supports saving and 
restoring the shell state when you leave, as well as many more features.

http://ipython.org/

The feature I think you want is this:

http://ipython.org/ipython-doc/stable/interactive/reference.html#session-logging-and-restoring

bpython is a more light-weight alternative. It doesn't have all the 
features of ipython, but it is closer to the standard interactive shell:

http://bpython-interpreter.org/

DreamPie is another alternate Python shell that might be worth 
investigating.

http://www.dreampie.org/



> Or to use python in the interactive mode and in some moments to run
> scripts, without quit() the interactive mode, and use for the script
> variables the one you have defined in the interactive mode?

Again, I expect that ipython will do something very like that.


-- 
Steven


More information about the Tutor mailing list