You can use subprocess.call(“/usr/bin/python”) to open Python shell within a piece of Python code. Now my question is is it possible to predefine some variables/functions before initialization of this shell? In other words, inside Python code, I can define a bunch of useful variables and functions and I want them to be available in the Python shell opened later by subprocess call. It is useful in the sense that sometimes you want a customized Python shell to test your environment.
You can use subprocess.call(/usr/bin/python) to open Python shell within a piece of Python code.
Share
You can do this using the
-iswitch. This will run a script, and then drop into the interpreter for interactive use.