Index

Module Index

Search Page

npplus.interactive module

Import most names in npplus for interactive use.

from npplus.interactive import *

This module should be imported only from PYTHONSTARTUP, except for similar interactive.py modules in other packages.


reloadx(module)[source]

Shorthand for reload(module); from module import *.

The module argument may be the module name as a string or the module itself.

Also injects symbol my into the module namespace, with value equal to the __main__ module. This is useful for interactive debugging with pdb.

Notes

To interactively develop a module, do this:

# You may want to softlink 'ln -s /path/to/module_or_package .'
# in your user site-packages directory (python -m site --user-site).
# See site module in python standard library documentation.
import module    # begin by importing your module or package
reloadx(module)  # same as from module import *
# test your module
import pdb       # use pdb.pm(), pdb.run("test...") to debug
# edit module.py (or package/module.py)
reloadx(module)  # reload module and re-import its symbols
# be sure to recreate any objects constructed from modified classes
# loop debug, edit, reloadx

The my debugging feature will only work if module is really a module, not a package; usually it should be the specific module you are debugging. After reloadx(module) you can do things like this from the pdb prompt:

(Pdb) my.plot(x, y)
(Pdb) my.savexy = (x, y)

In the latter case, after you quit pdb, the variable savexy will be present in your top level interactive namespace. Anything that is available in your interactive namespace will be available through the my variable in your pdb debugging session.