[Tutor] Redirecting output + calling dos commands with input tail

Jeff Shannon jeff@ccvcorp.com
Tue Jun 17 19:23:01 2003


cino hilliard wrote:

> 3. When I make a modification to shell.py I have to close the current 
> python.exe chevron >>>
> window and start another and  from shell import * again or open 
> another >>> and from shell import *
> Any way around this? I want to keep the last >>> because the previous 
> commands can be
> retreived with f3 and the arrow keys. The import shell.pycall etc 
> doesn't work in xp pro p4 either.


Yes, there's a simple way around this.  First, don't use 'from shell 
import *', use 'import shell' instead.  Now, every function that you're 
using from the file will be referred to as, e.g., shell.pypari() or 
shell.pycall().  This requires a tiny bit more typing (unless you have 
an IDE that does autocompletion, where it might *save* typing!), but it 
makes keeping track of which functions are yours and which are built-in 
to Python much simpler.  (It also reduces the risk of having one of your 
functions hide a built-in function by "stealing" its name.)  Now, when 
you make changes to your shell.py file, you can simply type 
'reload(shell)', and the module will be reloaded from the file (with 
your changes).

Jeff Shannon
Technician/Programmer
Credit International