def problem

clickron at webtv.net clickron at webtv.net
Sat Feb 10 16:13:04 EST 2001


I write this, save it. and run it.
def hello(): 
              print "hello"
       print "bye bye" 
hello() 
and I get this message 
hello
Traceback innermost last):
File "<pyshell27>",line 1, in ?
hello 
NameError: There is no variable named 'hello' 
What am I doing wrong? 
It works for me. My guess is that you are putting the function in a
file, saving it, running it, and then typing "hello()" into IDLE (or
PyWin). That would cause the error you report. Is the hello() function
call in the same file as the function? 
_________________________________

That's exactly what I'm doing. I go to IDLE, open a window, write the
function, save it, and run it. Then  I type in hello()
and get the error message. 

Now I retyped it, both with the function call  in the same file as the
function and without it. Did everything else the same and it works both
ways.

I don't know what's going on. How should I do it?

Ron




More information about the Python-list mailing list