Out of Date: THIS SECTION IS FOR HISTORICAL PURPOSES ONLY, PLEASE DO NOT USE.
The Python module spark.standard defines some useful things and installs them in the __builtin__ module, so that they are available from all other modules (especially useful when you are in the python debugger).
- M.<modulename>
- Returns the module object named by <modulename>. So that
submodules can be accessed, double-underscores in <modulename>
are replaced by ".". For example:
<<< M.spark__agent.dotest()
Is similar to executing:<<< import spark.agent
However, the "M" form does not add spark to the current namespace and being an expression rather than a pair of statements, it can be used in other expressions.
<<< spark.agent.dotest() - MM.<modulename>
- All SPARK python files include
from spark.version import *
Not only does this address Pyhton/Jython 2.1 versus Python 2.2 and 2.3 incompatabilities. It also sets a variable MARK_THIS_MODULE_TO_DROP. MM is like M, but when you use it to access a module, it deletes all python modules that have this variable set. Thus if you are editing some python files and want to make sure that the newest version of each python module will be loaded before you call spark.agent.dotest(), you would use the form:<<< MM.spark__agent.dotest()
- SHOW(x)
- Prints all sorts of useful information about x (even if the standard __repr__ and __str__ methods used to print the object raise exceptions and don't work). There is a bit of duplication in the information sometimes - feel free to improve on this if you want :-)
- APROPOS("xyz")
APROPOS.xyz
- Lists all modules that define something with a name matching *xyz*.
<<< APROPOS.abs
expandtabs ( spark.newgrammar ) = <function expandtabs at 3502050>
expandtabs ( spark.exception ) = <function expandtabs at 4492466>
expandtabs ( yappsrtz ) = <function expandtabs at 3502050>
abspath ( javapath ) = <function abspath at 5825154>
isabs ( javapath ) = <function isabs at 4864516>
expandtabs ( string ) = <function expandtabs at 3502050>
abspath ( os.path ) = <function abspath at 5825154>
isabs ( os.path ) = <function isabs at 4864516>
abs ( __builtin__ ) = <java function abs at 2550821>
The spark.standard module also exports the pdb.pm function and a function ipm. The pdb.pm function puts you into the debugger for the last exception thrown. The ipm function does this for the last exception thrown in an intention thread - quite useful if you want to get at an exception that killed off an intention.
The first thing I do after starting up a Python interpreter is
<<< from spark.standard import *That way if I get an error in the main thread, I can get to the debugger with:
<<< pm()Or if I get an error in an intention, I can get to the debugger with:
<<< ipm()NOTE: The python debugger only works in CPython not Jython.