Newbie Shell Editor Question

K

Kash

Hi Everyone,

I am new to python. I have just installed it. I am went to the python
website and used it to download python and a beginners tutorial. I set
the environment variables as explained in the faq.
However when I start idle and run a program from it; I get the
following types of errors; however I can run the same programs no
problem from my command prompt.
Can anyone please tell me what I am doing wrong? I thought Idle was
used to test programs in. I am able to open a new window and write
code, save it and then run that code; but just not if I type it into
the main idle window directly.
Any help would greatly appreciated, thank you.
Kash

This is my error:
----------------------------
IDLE 1.1
Traceback (most recent call last):
File "<pyshell#4>", line 1, in -toplevel-
hello
NameError: name 'hello' is not defined
Traceback (most recent call last):
File "<pyshell#5>", line 1, in -toplevel-
hello.py
NameError: name 'hello' is not defined
 
H

Harlin Seritt

The Python shell you get with IDLE is actually not a system shell like
cmd.exe or sh, bsh, csh etc. It is a shell that allows the Python
interpreter to evaluate each line of Python code as you type.

This is why when you type 'hello.py' it tells you 'hello.py' is not
defined. On a higher level it simply tells you: you haven't initialized
this object called hello.py in memory and therefore the error. Also you
can't run python anything because in the interpreter python *hasn't*
been assigned any value.

Also, you can't quit the Python interpreter shell by typing exit.
You'll need to do a Control-D & Enter ;-)

Hope this makes sense.

Good luck.

Harlin Seritt
 
R

runsun pan

whatever you type after the >>> is either a statement that command
python to do something (like "print 'hello'"), or an object that might
or might not contain/return a value. The 'hello' you typed (the one
that caused error) is simply a word. It is not a command, it is not a
variable, it is not an object. Compare to this:
3

when you typed :

python will try to look for any variable named 'hello' in order to
investigate its content for return. But it can't find it because you
didn't define it.
 
T

Tim Roberts

Kash said:
Hi Everyone,

I am new to python. I have just installed it. I am went to the python
website and used it to download python and a beginners tutorial. I set
the environment variables as explained in the faq.
However when I start idle and run a program from it; I get the
following types of errors; however I can run the same programs no
problem from my command prompt.
Can anyone please tell me what I am doing wrong? I thought Idle was
used to test programs in. I am able to open a new window and write
code, save it and then run that code; but just not if I type it into
the main idle window directly.
Any help would greatly appreciated, thank you.
Kash

This is my error:

Idle is already running the python interpreter. You don't need to start
another copy. It is just like you had typed "python" at a command line.
If you want to run a script in a file, you have to use the IDLE menu to do
so. I don't know IDLE, but it's probably something like File->Run.

THAT'S the way you use IDLE.
 
S

Scott David Daniels

Tim said:
Idle is already running the python interpreter. You don't need to start
another copy. It is just like you had typed "python" at a command line.
If you want to run a script in a file, you have to use the IDLE menu to do
so. I don't know IDLE, but it's probably something like File->Run.

Just in case that's not enough of a clue:
ctrl-O to open the file with a file chooser dialog
F5 to run the currently open file.

Or, if you like to click:
File -> Open (choose file)
Run -> Run Module


--Scott David Daniels
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,232
Messages
2,571,168
Members
47,803
Latest member
ShaunaSode

Latest Threads

Top