In order to run these tutes you need to have a copy of the Python programming language installed on your machine. These tutes assume Python version 2.6, although Python 2.4-2.7 should also work fine. There is a new version of Python starting with 3. These tutes may, but most likely won’t (since the syntax of print has changed), work for it.
If you are running Linux, Python is probably already installed on your computer. If not, you can install it through the package management system for your distribution. Otherwise (ie if you are running an alternative operating system), you can get Python 2.6 here. In either case you will probably need the help of an adult to install it for you.
Once Python is installed you need to get to an interactive Python prompt -> this is the >>> you see in the tutorials. This is done by starting a command shell and typing the command python <return>. Again, you may need to get an adult to show you how the first couple of times. Once you have a prompt up you will be able to tell whether you have the right version. When the Python shell starts up it tells you what version is running:
Python 2.6.2 (r262:71600, Oct 24 2009, 03:15:21) [GCC 4.4.1 [gcc-4_4-branch revision 150839]] on linux2 Type "help", "copyright", "credits" or "license" for more information.
Python comes with its own help service:
>>> help Type help() for interactive help, or help(object) for help about object. >>> help() Welcome to Python 2.6! This is the online help utility. If this is your first time using Python, you should definitely check out the tutorial on the Internet at http://docs.python.org/tutorial/. Enter the name of any module, keyword, or topic to get help on writing Python programs and using Python modules. To quit this help utility and return to the interpreter, just type "quit". To get a list of available modules, keywords, or topics, type "modules", "keywords", or "topics". Each module also comes with a one-line summary of what it does; to list the modules whose summaries contain a given word such as "spam", type "modules spam".
Once help has started try ‘keywords’, ‘topics’ and ‘modules’ as it suggests.
Wherever you see a code extract, that’s a print out of what I actually typed with my fingers in my Python interpreter. You’re supposed to type it into yours as well (cut and paste is also fine). In some cases if you don’t type it in yourself, you won’t understand what’s going on because the printout doesn’t show that different things are put on the screen at different times. Just type one line at a time and indentation is important. So:
for i in range(5): print i
is completely different from:
for i in range(5): print i ^ note the different indentation here for the print statement.
The precise number of indents is not all that important as long as all indents are consistent. So it doesn’t matter if you can’t count my whitespaces correctly as long as the start of all your code lines up at the same place (for each code block). So, for example, if I’ve got 4 spaces in front of all my indents, if you do 3 or 5 that’s fine, as long as you do the same number for each of them (ie all lines with 3 spaces and not, say, 3 on one line, 5 on another etc).
Now for Something Completely Different:
After that click the links in the sidebar to go to older tutorials (starting in July 2010 and working forward) and catch up.