[Tutor] Help with setting path
alan.gauld at btinternet.com
Sat Nov 3 09:37:26 CET 2007
"sith ." <sith618 at yahoo.com> wrote
> For example, here is the traceback for a simple file I made and
> tried to run in IDLE:
> # test.py
> x = 1 + 1
> print x
> In IDLE, I tried to run it by typing test.py
That's the problem.
You cannot run Python scripts in IDLE by calling
them like that. You should open the file using the File->Open menu
and then run it using the Run menu. IDLE is not intended for running
scripts but for writing them. To run a script just use a DOS box or
double click the script from Windows Explorer (but in your example
it will close before you can read the output! - you need to put a
raw_input() call at the end to stop that)
> However, when I open the file in IDLE using the menu,
> and then run it also from the menu, it works.
Thats the correct way to do it.
You don't need to use IDLE to run a program, only to edit it.
The >>> prompt in IDLE is a Python interpreter and expects
actual Python commands, not script names. On a recent
thread it was mentioned that IPython (which is another Python
interpreter) has some special commands including a run
command that does accept filenames. If that is something
you need you might like IPython.
More information about the Tutor