I originally wanted to learn Python because I wanted to make a computer game. I had taken several programming classes in college (C, C++, and Java) but nothing really serious. I’m not a Computer Science major and I don’t program on a professional level.
I didn't really like the low-level work involved with C/C++. Things like pointers, memory management, and other concepts were difficult for me to grasp, much less effectively use. Java, as my first programming class in school, didn't make any sense. I had never used an object-oriented language before and object-oriented programming (OOP) concepts gave me fits. It probably didn’t help that my Java class wasn’t actually real Java; it was actually Microsoft’s “custom” version: J++. So not only was I learning a language that had little practical use (J++ added and cut many features found in real Java), but the programs didn’t work correctly. Ultimately the class was cancelled near the end of the semester and everyone received full credit.
These problems, and issues learning other programming languages, left a bad taste in my mouth for programming. I never thought I learn a language well enough to feel comfortable using it, much less actually enjoy programming. But then I heard about Python on a computer forum, and then noticed several other mentions of the language at other sites around the Internet. People were talking about how great the language was for personal projects and how versatile it is. I decided to give programming one more try and see if Python was the language for me.
To give me more incentive to learn the language, I decided to recreate a role playing game from my childhood as a computer game. Not only would I have a reason to learn the language but, hopefully, I would have something useful that I could give to others for their enjoyment.
Why Python?
Python is regarded as being a great hobbyist language yet extremely powerful. It has bindings for C/C++ and Java so it can be used to tie large projects together or for rapid prototyping. It has a built-in GUI binding via Tkinter but other GUI builders are available. It can be used in a real-time interpreter for code testing then built into a normal "executable".
Python is classified as a scripting language. Generally speaking, this just means that it’s not compiled to create the machine-readable code and that the code is “tied-into” another program as a control routine.
It’s also considered a high-level language, meaning it takes care of a lot of the grunt work involved in programming. For example, Python has a built-in garbage collector so you, as a programmer, don’t really need to worry about memory management and memory leaks.
The main emphasis of Python is readable code and enhancing programmer productivity. This is accomplished by enforcing a strict way of structuring the code to ensure the reader can follow the logic flow and by having an “everything’s included” mentality; the programmer doesn’t have to worry about including a lot of different libraries or other source code to make his program work.
Why Another Tutorial?
Even though there are several great tutorials at the [http://www.python.org||Python web site] in addition to many books, my emphasis will be on the practical features of the language, i.e. I won't go into the history of the language or the esoteric ways it can be used. Though it will help if you have programmed before, or at least can understand programming logic and program flow, I will try to make sure that things start out slow so you don’t get confused.
Getting Python
As of this writing, Python 2.6 was just released. However, my experience is with Python 2.4 and 2.5. Much of my knowledge was gained from reading books written for version 2.2. As you can see, it doesn’t necessarily mean your knowledge is obsolete when a new version comes out. Usually the newer versions simply add new features, often features that a beginner won’t have a need for.
One thing to be aware of is that Python 3.0 is due to come out in a few months. This version is supposed to break compatibility with programs written in 2.x versions. However, much of the knowledge you gain from learning a 2.x version will still carry over. It just means you have to be aware of the changes to the language when you start using version 3.0. Plus, the install base of 2.x is quite large and won’t be going away for quite some time.
You can download Python from the [http://www.python.org||Python.org] (for Windows) or it may already be installed on your system if you're using a Mac, Linux, or *BSD. However, the Unix-like operating systems, including OS X, may not have the latest version so you may wish to upgrade, at least to version 2.5.
I'll assume you can figure out how to get the interactive interpreter running; if you need help, read the help pages on the web site. Generally speaking though, you open up a command prompt (or terminal) and type “python” at the prompt. This will open a Python session, allowing you to work with the Python interpreter in an interactive manner.