I am writing a short tutorial, and would like to be able to run the examples therein using python's doctest using
python -m doctest foo.txt
There is a point in the tutorial at which I want to start using a new, clean python interpreter. Is there a mechanism for doing this?
If all you want is to start a new python interpreter inside the python interpreter you can just issue the command: os.system('python')
Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> dir()
['__builtins__', '__doc__', '__name__', '__package__']
>>> import os
>>> dir()
['__builtins__', '__doc__', '__name__', '__package__', 'os']
>>> os.system('python')
Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> dir()
['__builtins__', '__doc__', '__name__', '__package__']
>>> quit()
0
>>> dir()
['__builtins__', '__doc__', '__name__', '__package__', 'os']
>>>
if however, you want to restart or reset python interpreter and not start a new python interpreter like above you could look at this solution. I haven't explored it but should help you get started of.