def problem
Greg Jorgensen
gregj at pobox.com
Sat Feb 10 22:55:44 EST 2001
In article <10844-3A85AEE0-152 at storefull-161.iap.bryant.webtv.net>,
clickron at webtv.net wrote:
> 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 think you had a typo or indentation problem somewhere.
What you may be trying to do is import the hello module:
---
# hello.py
def hello():
print "hello, world"
---
>>> import hello.py
>>> hello()
hello, world!
This is explained in the Python tutorial at http://python.org.
--
Greg Jorgensen
Portland, Oregon, USA
gregj at pobox.com
Sent via Deja.com
http://www.deja.com/
More information about the Python-list
mailing list