progman.py: BASIC-like LOAD(), NEW() and RUN()
program management functions for Python.
This module provides program management functions similar to those of
interactive BASIC interpreters:
- NEW() - restore interpreter state to the state at the time of
first importing this module
- LOAD('name') - restore interpreter state and import a file into
__main__ without executing its startup code. The name does not
include the .py extension and is looked up using the same search
path as modules. If name is omitted, the currently loaded program
is reloaded.
- RUN(args...) - run __main__'s startup code. Any arguments are
converted to string, split and assigned to sys.argv to
emulate a script started from the command line. argv[0] is set
to the script name. A REFRESH() is automatically performed before
running.
- REF(), REFRESH() - reload any modules whose source has changed on
the disk. This includes __main__, but excludes any modules already
loaded at the time of importing this module. Refreshing __main__
does not restore the intepreter state first. Use LOAD() for that.
- SAVE() - sorry, no SAVE()...
Startup code is defined as statements at indent level 0 after which
there are no further function or class definitions.
Not of much use in a module or standalone script, this module
is designed to be imported and used in an interactive interpreter.
This module should be imported as early as possible so it can
later restore the interpreter state correctly.
If you import this module after importing some modules they will
be considered part of the base state and therefore available after NEW()
Oren Tirosh 
Back