I'm a newbie running my very first module . . .

Specs:
Mac OSX 10.6.6
Python 3.2
IDLE v 3.2
Tk v 8.5

I saved this module to my desktop
> # File: chaos.py
> # A simple program illustrating chaotic behavior.
> 
> def main():
>     print("This program illustrates a chaotic function")
>     x = eval(input("Enter a number between 0 and 1: "))
>     for i in range(10):
>         x = 3.9 * x * (1 - x)
>         print(x)
> 
> main()


When I open and run this module in IDLE's shell the application hangs. This can 
sometimes be 'fixed' by going to Run > Check Module and then running the 
module. But I have a feeling I'm doing something wrong. Is there a better way 
to import the file into IDLE so I can run it without crashing the app?

Also, when it works correctly, IDLE won't run the program again via the >>> 
chaos.main() statement. I get this:
> Traceback (most recent call last):
>   File "<pyshell#1>", line 1, in <module>
>     chaos.main()
> NameError: name 'chaos' is not defined


Thanks!

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to