On Computers

Playing with Python

Gail Allinson gail@oncomputers.info

18 January 2004

Python is an open source programming language. It is available for Windows, Mac, Linux and Unix.

I've just started to play around with it so I'm not going to teach what you can do with it, or how you do it because I don't know much myself yet.  What I am doing is letting you know that it is out there for your learning pleasure and giving you some of the best links for learning it yourself. I am also going to give you some instant gratification by pointing you to one of the nicest, free, solitaire game suites around: PySolitaire for Windows or PySol for the 'nixes.

A nice thing about Python is that it costs you nothing to download it or learn it. It is only a matter of time and will.

Because Python comes with OS X and Linux I'm going to give the Windows folks a little extra help here. There are two places to download Python for Windows: Python.org or ActiveState. You really only need to install one. I suggest that for now you start with ActiveState.  While it runs on both versions of Python the authors of the PySolitaire game recommend ActiveState.

So choose your weapon, read the installation instructions, and do it!

Python Programming Language (Python.org version of Python)

ActiveState ActivePython free Python open source language distribution (Active State version of Python)

Now that you've got Python installed on Windows, the next step is to check your path. Your path is probably going to be one of two places.  In 9x versions of Windows, it is going to be in your autoexec.bat file (it will be on your C drive)  You can use Notepad to edit autoexec.bat and add the path to your Python directory. It will look something like this:


If you are using Windows 2000 and XP, the path can be modified in System Properties (right click on My Computer and click Properties). Choose the Advanced Tab. Click on the Environment Variables button and edit the Path under System Variable.

If when you look at the path, Python has already been added (I believe that the Active State installer will do that), you can safely leave it alone as long as it does match the path to your current Python directory.

Now for the fun. Download PySolitaire (I've provided the link to PySol for you 'nix types) and install it.

PySolitaire (for Windows)

oberhumer.com PySol Solitaire Home Page (for the 'nixes)

Once you have downloaded PySolitaire, it can be installed like any other windows program. If you have installed Python and your path is correct, PySolitaire will start up (it takes a while the first time) and you are in business.

That's all for today, but now that you have Python installed, why don't you join me in looking at these docs and tutorials? Whatever you do, be sure to have fun :-)

Documentation, tutorials, and help:

Beginner's Guide to Python (Python.org)

MacPython Website (Python for the Mac)

ActiveState O'Reilly Python cookbook code samples ratings review

Happy Python-ing!


Jack's Two Cents Worth About Python

Jack 'daWabbit' Imsdahl jack.imsdahl@oncomputers.info

I'm an enthusiastic Python user. No, I'm not terribly knowledgeable or a good coder. But I had to have something to learn with and use, and after a bit of research, I chose Python. Java and Python seem to be the beginner's languages of choice, these days, and I chose Python because it appears a bit less complex than Java. It takes me forever to get things such as this right. Even so; I'm happy with Python. It works for me. And since I use both Windows and Linux, the cross-platform capabilities of Python are important to me. Almost everything I write on one platform will run on the other, with only a very few and very minor exceptions, so far.

In 'the old days' the choice was BASIC, QBasic or derivatives thereof. These languages served a real purpose, offering ease of use and an understandable syntax, but suffered some genuine limitations, too, especially in mathematics capabilities. Never the less; BASIC, et al, did yeoman service for lots of us lesser geeks for many years. I know of a high-pressure valve factory whose quality control once ran on banks of Radio Shack Color Computers running BASIC and I personally participated in a project that controlled literally hundreds of model railroad components using similar machines running QBasic. It did have it's uses.

Times change. Needs and capabilities change, too. Guido von Rossum invented Python to be the BASIC of the modern age. While he was at it, great capabilities were added. Python emerged a full-fledged object oriented language of great capabilities and with a rather small run-time environment. This is why you see so many Linux installers written in Python; the code necessary for the computer to run Python scripts is smaller than the run-time for any other modern language I am aware of. Plus; it integrates well with ANSI C (by design) which the core of Linux is written in. One can augment Python code with C modules (and vice versa) easily.

You can certainly write entire applications in Python, but for us beginners, that's not the way to think about it because complete applications quickly grow to be a rather intimidating prospect. Think instead in terms of small scripts to accomplish some task more quickly and easier than we could by opening a full-fledged application and doing it there. The majority of my scripts do repetitive calculations with a range of variables. It's often actually simpler and faster to program in Python that than it is to open a calculator or spreadsheet, set it up and run it there! (I find it more satisfying and fun, too.)

Tutorials for Python are not scarce. There are several good ones. The one Gail linked to at the Python.org site is a fine one. I also like the “How to Think Like a Computer Scientist” series available at ibiblio.org; http://www.ibiblio.org/obp/thinkCSpy/ . These cover Ruby, Java, C++ and Python and are definitely worth a look. To the best of my knowledge, there are no “Python for Dummies” style books of any worth. However; the documentation landscape changes rapidly and there may indeed be such texts by now.

Should you wish to program in an environment other than the ones provided by the two Python distributions, that is easily done with freeware or proprietary software. I have Active State's Komodo IDE (Integrated Development Environment) and use it some. Mostly, I stick with IDLE, the standard Python environment, or work in Crimson Editor (http://www.crimsoneditor.com/) which has among it's capabilities, color syntax highlighting for all the languages I use and more, Python among them. There are dozens of other choices, if you feel a need to explore them.

Go have some fun with it.


© 2004 Gail Allinson and Jack Imsdahl

Back • Home • Up • Next

© 2002 - 2004 by On Computers and the Videotex Services Coalition.