|
This should be pretty easy.
Windows
You have two options. The basic distribution of Python (2.4.2) is available here. However, there's also a free IDE (integrated development environment) available here. The latter option (ActivePython) is probably easier to work with, and doubtless has a lot of cool features. Let's go with that, why don't we.
Mac
OS X 10.2 and higher comes with Python pre-installed. You don't have to do anything — but I'd recommend that you go here, download the installer, and run it. For one thing, this will update your version of Python. For another, it will provide you with an IDE of your own (PythonIDE). More importantly, it'll provide a package manager, which will be important later.
Linux/Other
You guys probably know how to fend for yourselves. Source tarballs can be found here.
Testing It
Let's put together a Python program. I promised interesting applications, but it'd be a shame to skip past Hello World -- it's a rite of passage. Open up ActivePython or the PythonIDE and create a new file (File|New). Enter the following:
print "hello world"
It's hardly worth explaining, but I may as well: this single line calls the print function and passes it a string literal with the contents hello world. Don't worry about what a function is or what a string is or what a literal is (if you do know these things, feel free to feel smug about that fact). Just know that saying print "something" spits 'something' out to the screen, and that the quotation marks in the program aren't part of the output — in this case, they let Python know that it should treat the text hello world differently than it treats the text print.
Once you've got that entered (raise your hand if you're still working), save the file somewhere, then hit the "Run All" button in PythonIDE (Mac) or the "Check"/Little Running Guy button in ActivePython (Windows). ActivePython will pop up a "Run Script" box — just hit return.
The program should spit out the expected string in an output window (PythonIDE will create a new window; ActivePython sends output to the "Interactive Window" that should have opened when you started the program).
Astounding, isn't it? Well, don't worry, we'll be doing real programming soon. For now, just make sure that you understand how to create, load and save Python files — it's all done in exactly the same way as you'd manipulate documents in MS Word.
Also worth noting: these files are simply text files (usually with names ending in .py; that's just the convention). You can edit them in Notepad or TextEdit if you'd like, and run them from the command line by typing "python nameofprogram.py" (assuming you're in the same directory as the file, and the Python executable has been correctly placed in your path by the ActivePython or MacPython installer).
That's it for now. Next up, the meat of any programming language: variables, control structures and functions (not necessarily in that order). By the end of that lesson, you'll be ready to create some of the world's crappiest videogames. Let me know in comments if you had trouble with the installation or with Hello World.
|