Problem solve Get help with specific problems with your technologies, process and projects.

A Python introduction

Python is a ten-year-old Windows programming language. For those of you who know it well, this tip can act as a refresher for some of the uses of Python. For those of you who don't use it, this tip can help you decide whether this language can be of value to you.

Python can be used in the following areas to improve your business processes:

A macro language
You can use Python to add a macro language or scripting capability to existing applications, and it's simple enough for user-level scripting with a minimum of training. Developing a new language is often thought of as a task for the big boys in Redmond and no one else. Python is an off-the-shelf macro language you can plug in to your existing tools at a variety of levels.

A rapid prototyping tool for object models and algorithms
Designing software in C++ is expensive and time-consuming, although superb results can be achieved. You can create objects in Python with fewer lines of code and fewer hours than any other language we know, and there is full support for inheritance (single and multiple), encapsulation, and polymorphism. A popular approach is to prototype a program in Python until you're sure the design is right, and only then move to C++. An even more popular approach is to profile the Python application and rewrite the speed-critical parts in C++.

A testing tool
New programs and code libraries need testing. Experienced developers know that building a test suite for a new function or program saves them time and grief. If a program works with files as its input and output, Python scripts can generate input, execute the program, look at the output, and analyze it. If the data is the issue, you can write disposable scripts to check identities in the data.

Data cleaning and transformation
You may need to move data from an old database to a new database, refreshing daily for months during a changeover, or build interfaces that let data flow between incompatible systems. This can be a tedious and error prone process when done by hand, and you always miss something and have to redo it later. Python's native support for lists and dictionaries makes complex data transformations easy, and the interactive mode lets programmers view the data at each stage in the process. Scripts can be written to transform data from the source to destination and run as often as needed until they do the job right.

Python as glue
Incompatible systems often need to be tied together, and processes need to be automated. Python supports all the key technologies for integration; it is equally happy working with files, network protocols, DLLs, and COM objects, and offers extensive libraries to help you get at almost any kind of data. It's well suited to controlling other packages, doing system-administration tasks, and controlling the flow of data between other systems.

The information for this tip was garnered from Python Programming on Win32 by Mark Hammond and Andy Robinson, O'Reilly and Associates, 2000. Available at

Dig Deeper on Enterprise infrastructure management

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.