Installing Python

Getting started with Python is easy, you just need to download the python installation package and install onto your computer.

Versions

As of this writing, Python 3.1 is the latest version, though I won’t be using the latest bleeding-edge build for my exercises. There’s nothing wrong with 3.1, but third party package support for the packages I use can trail the latest release by a version or two. If you plan on installing third party libraries not provided in the standard Python release, you will want to use a slightly older version. My exercises will be based on the latest Python 2.6.

Which Python foundation should I use?

There are different ways to obtain Python for the Windows platform. Two of the most popular distributions are from the Python foundation and Activestate Software.

Python.org

The site http://www.python.org, maintained by the Python Software Foundation, is the main portal for information on Python. Python.org contains news, documentation, information on the latest releases, download source for current and previous versions of Python, and binary install files for Windows. The latest version, as well as older versions of Python, can be found at http://www.python.org/download. This is the Python foundation that I typically use, the examples that follow will be based on Python 2.6.

ActiveState Python

ActiveState Software provides software solutions for individuals and businesses, including a complete download package containing Python executables and documentation called ActivePython. The package is non open source and available with an OEM license, which can be important in some corporate environments. Please refer tohttp://www.activestate.com/activepython for more information. Python luminary Alex Martelli offers a concise description of Why ActiveState in this StackOverflow post.

Build from Source

Source code for Python is available at http://www.python.org/download, and while it is possible to create a working Python installation for Windows by compiling from source, it’s beyond the scope of these exercises.

Python Modules

One of the wonderful things about Python is the excellent library support for the language. Python is “batteries included”: a large number of libraries are provided out-of-the-box, right in the standard distribution. Other modules are available from a variety of sources, chances are you can find a module that helps you solve a problem with a simple web search. I’ll use a variety of third party modules for the exercises that follow, but you’ll at least need to start with the pywin module. You can find the appropriate pywin for your Python 2.6 installation at http://sourceforge.net/projects/pywin32/files

Resources

I won’t be covering the basics of Python, I suggest you check one of the many other resources. The links listed on http://www.python.org/doc are an excellent starting point, many people also like the Dive into Python book at http://diveintopython.org. You can also find a number of other resources by searching for learn python.

Thanks — Dan

What is Python Excels?

It’s time to give back. And get back. I’ve been Googling your blogs, your wikis, your stackoverflows for years. Grabbing a program here, a snippet there, and using it to build my scripts that do anything from prepping SAP data for an Excel worksheet pivot table, to dumping tables from Oracle DB XE into a spreadsheet, to formatting time card data from a restaurant POS system, to summing times from an Optical Proximity Correction log file, to characterizing random behavior in a Critical Area simulator, to constructing a QA test flow for an automatic scan test pattern generation and insertion tool suite, to dozens of other minor tasks I’ve long forgotten. Thanks for your postings, your hints, your ideas and your links to other helpful pages. I can only hope that a few people find my postings useful. If you like what you see, let me know.

I got into Python a few years back, an unrequited Perl lover who lost patience and faith waiting for Perl 6 to make its appearance. I’ve written hundreds of Perl scripts, and it was my tool of choice for many years. Perl is an amazing, vexing language, still used very very heavily in the Electronic Design Automation industry where I work. For me, I wondered what else was out there, and after taking a sojourn into the world of Ruby, I was able to conquer my ridiculous aversion to white space and arrived in the world of Python.

I’ll be sharing some ideas from the Python programs I’ve written, and talk about what problems were solved. I like to share work that is as complete as possible, so in most cases you should be able to download the script and try it right away for yourself. We won’t be using the latest, most bleeding edge version of Python, because some of the scripts require other modules that may not be available yet in the latest release. Maintaining good Pythonic style is important, and I try my best, but if you spot something in my code that could be done better, leave a comment and share your knowledge.

So sit back and let’s get ready to write some Python!

(This post originally published July 3, 2009)