Si
I grew up around computers. Before I was born, my dad worked in computer graphics (running Pascal on a room-sized computer, designing typefaces and such), and he kept up with the industry even after he left the business. The first computer I used was an Apple Macintosh Classic II that my dad had bought to write his graduate thesis on (being the techno-savvy guy he is, he had maxed out the RAM at 8 whole megabytes), and I still keep it around in my room back home to play Zork on. I grew up with my dad's hand-me-down computers, always Macs. I've held a couple of jobs working with computers, such as upkeep and maintenance work act a couple of places, and for the past two summers I worked at Apple's flagship store in Chicago. I've gotten to know a lot of the ins and outs of the Mac OS, and a bit of Windows (although I avoid Windows when I can), but haven't looked very far under the hood before.
The first chapter seems pretty straightforward, although there is a hitch I've run into. I copied the chaotic function script into TextWrangler to give it a try, and while I can tell TW to run the script through the Terminal, I can't figure out how to command the terminal to locate and run the .py file I saved. The book makes it look as though all I should have to do is to activate the Python interpreter and type "import " but that just gives me an error message that reads:
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ImportError: No module named chaos
So, maybe I misunderstood or something. Either way, the script itself does run fine when I send it to Terminal directly from TextWrangler, so at least I'm doing something right.
Jim, Sun at 5pm
Hi Si.
I'm guessing that the problem you're having is that when you're
in the Terminal (at the command prompt) you're not in the same
directory as where you saved the chaos.py file from the text editor.
The error is essentially saying "I can't find the chaos.py file you're
trying to read in." It has a list of directories it looks in, including
the current directory.
Here are a few commands you can try at the shell prompt (i.e. from Terminal).
(Don't type the $, I'm just using that symbol as the computer's prompt.
And anything after a # is my comment.)
$ pwd # print working directory
/Users/mahoney
$ cd Desktop # change directory to the desktop
$ ls # list the files there
chaos.py # a file created with TextWrangler on my desktop
$ python chaos.py # here's one way to run it
This program illustrates a chaotic function ...
$ python # here's another
Python 2.3.5 (#1, Mar 20 2005, 20:38:20)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1809)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import chaos
This program illustrates a chaotic function ..
Also notice that in TextWrangler (assuming that's what you're
using on your Mac) under the "#!" menu (more on why it's called
that later) one of the choics is "Run in Terminal". 'Nuff said.
Finally, when you're pasting text from programs or the command line
here into the wiki, leaving whitespace (a space or a tab) at the
beginning of each line tells the wiki to leave the text as is
(instead of doing line wraps) and to
put in in one of those yellow boxes.