Re: Really newbie help

Ken Manheimer (klm@NIST.GOV)
Tue, 28 Feb 1995 23:06:44 -0500 (EST)

I'm a big emacs user, but don't tend to use the emacs python code-load
routines that guido mentions. I typically develop code by editing and
import/reload/reload/reloading modules within an interactive session. I
interactively experiment with components, and use pdb.run() and pdb.pm()
when suitable.

A few small things that i find invaluable:

1. i run the interpreter in the same directory as the module, and have
'.' on sys.path, so i can easily load the module with preference.

ii. structure the module so it is as reloadable as is feasible - clearly
identify components that should be reinitted on each fresh load,
versus components that should persist after first initialization. that
better enables the reload/retest cycle.

c. emacs shell-mode command recall - eg, ESC-p, ESC-r - are big benefits
when repeating commands and command sequences within emacs python-
interaction mode.

Towards the end of a module's development, particularly when the module is
meant to be used as a script, i will sometimes use the python '-i'
interpreter option. This tells the interpreter to remain loaded if a
script hits an uncaught exception, allowing you to post-mortem debug. Eg:

% python -i larch.py
[larch errors blow away the run...]
>>> import pdb
>>> pdb.pm()
> ./larch.py...
...
(Pdb) [post-mortem examination]

Really really handy for zeroing in on obscure problems in complicated
scripts...

But the other stuff - the ability to intersperse experimentation,
debugging, and exercise of module components - is particularly crucial
for someone like me - i'm most comfortable being able to do at least some
"exploratory" programming, and sometimes find it crucial.

I hope this is helpful - it sounds like you've got a world of options to
explore...

ken
ken.manheimer@nist.gov, 301 975-3539