[Pythonmac-SIG] Newbie environment questions

Christopher Barker Chris.Barker at noaa.gov
Tue Jan 17 18:55:36 CET 2006


Ken Brooks wrote:
> Still nothing changes!  So how does the debug loop work?  How can I
> reload a module short of relaunching the environment??
   ^^^^^^

You've just inadvertently answered your own question. That's what we 
mean when we say "Python fits your brain":

 >>> reload(foo)

Python caches modules so that if one module is imported in ten different 
places, it doesn't reload them each time. To force a reload you use, 
appropriately enough, the reload function.

> 2. I really wish for the "doskey" feature that lets you easily
> retrieve and edit a line previously typed to the interactive
> interpreter.  Does it exist here?

Yup. It's called readline. Apple doesn't ship it with OS-X, because it's 
licensed under the GPL, but you can install in separately, or you can 
install a new version of python that has it.

See:
http://undefined.org/python/

for a newer Python, and:

http://www.pythonmac.org/packages/

For an assortment of add-on packages

There is a readline for th python 2.3 that came with OS-X 10.4 there. It 
may work with 10.4 also, if you install "TigerPython23Compat" from that 
page also.

All that being said, you might want to try one of the fancier python 
shells for interactive use, like ipython. Or, just write your entire 
script in a file (or multiple files) and restart python each time. It's 
rare that something take that long to run that re-starting is a problem. 
You can start it with:

$ python -i MyScript.py

and you'll get the interpreter prompt when it's done running.

-Chris


-

Christopher Barker, Ph.D.
Oceanographer
                                     		
NOAA/OR&R/HAZMAT         (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov


More information about the Pythonmac-SIG mailing list