[Tutor] Working with interactive Python shell

Josep M. Fontana josep.m.fontana at gmail.com
Wed Nov 24 13:32:44 CET 2010


Hi,

When a thread gets too long and new subtopics appear it gets pretty
hard to keep track of what has been said by whom and what has been
answered. Anyway, in one of the threads I started, Steven d'Aprano
gave me a very nice response telling me what his preferred working
environment was. This prompted the following question from me which
was not answered due to the fact that was one of the many subtopics
that emerged from the original question. I'm still interested in
finding out about this in case anybody can give me an answer. I
reproduce my question to Steve:

-------
One question for Steve (or for whoever wants to answer): you say you
have a terminal with two tabs (neat, I wonder whether I can get tabs
as well for my terminal in OS X) and when you need to do debugging you
turn to your interactive python terminal and do;

import filename  # first time only
reload(filename)  # all subsequent times

If I do this with a "normal" python file (filename.py), I get the error:

"ImportError: No module named py"

This is if I enter the file name with the .py extension. If I just enter the
file name without the extension, everything seems to work fine and I
don't get any error message but then when I call a variable I get a
message saying "'X' is not defined".
--------------

I'm wondering whether I'm doing something wrong or whether I didn't
properly understand what Steve was saying about working with the
interactive Python shell. If I understood correctly, one can import a
Python script into the interactive shell (not just modules) and then
test different things from the prompt. I've tried to import various
files following Steve's instructions but I get the errors I describe
above.

Josep M.


More information about the Tutor mailing list