- Shopping Bag ( 0 items )
Python is growing in popularity; based on download statistics, there are now over 450,000 people using Python, and more than 150,000 people using Python on Windows. Use of the language has been growing at about 40% per year since 1995, and there is every reason to believe that growth will continue.Despite Python's increasing popularity on Windows, Python Programming on Win32 is the first book to demonstrate how to use it as a serious Windows development and administration tool. Unlike scripting on Unix, Windows ...
Python is growing in popularity; based on download statistics, there are now over 450,000 people using Python, and more than 150,000 people using Python on Windows. Use of the language has been growing at about 40% per year since 1995, and there is every reason to believe that growth will continue.Despite Python's increasing popularity on Windows, Python Programming on Win32 is the first book to demonstrate how to use it as a serious Windows development and administration tool. Unlike scripting on Unix, Windows scripting involves integrating a number of components, such as COM or the various mail and database APIs, with the Win32 programming interface. While experienced Windows C++ programmers can find their way through the various objects, most people need some guidance, and this book is it. It addresses all the basic technologies for common integration tasks on Windows, explaining both the Windows issues and the Python code you need to glue things together.Topics include:
This is the first book to demonstrate how to use Python as a serious Windows development and administration tool. It addresses all the basic technologies for common integration tasks on Windows, explaining both the Windows issues and the Python code needed to glue things together.
Throughout this book we will talk about cases where Python has solved problems in the real world. Both of the authors use Python in their daily work and we will present a couple of examples how we are personally using Python to solve real world problems.
A Japanese Python?
One of the authors is currently working for a global investment company which is internationalizing its core applications to work with Far Eastern markets. The company's client platform is Windows, and core data is stored on Sybase servers and AS400 minicomputers, data flows back and forth among all three platforms continually. All three of these systems represent Japanese characters in totally different ways and work with different character sets. It was necessary not only to develop a library to convert between these encodings, but also to prove that it worked with 100% effectiveness for all the data that might be encountered in future years.
The first stage was to code up the conversions in Python, based on published algorithms and lookup tables. The interactive prompt let us look at the input and output strings very early on and get all of the details right working with single, short strings. We then developed classes to represent character sets' and character maps and fed in the published government character sets - very easy to do with Python's lists and dictionaries. We found subtle holes in published information and were able to correct for them. Having done this, we were able to prove that round-trip conversion was possible in many cases, and to identify the characters which would not survive a round trip in others.
An experienced C++ programmer then wrote a DLL to carry out String translations at high speed. Having a Python prototype allowed us to test the output very early on and compare the output. Python also generated test data sets with every valid character, something that would have taken months by hand. A Python wrapper was written around the DLL, and we wrote scripts to perform heavy-duty tests on it, feeding large customer databases through all possible conversions and back to the start. Naturally the tests uncovered bugs, but we found them all in two days rather than in months.
The DLL was then put to work converting large amounts of report data from mainframe to PC formats. Initially, a Python program used the DLL to perform translations. It would scan for files, decide what to do with them based on the names, break them up, and convert them a field at a time, and manage FTP sessions to send the data on to a destination database server. It also generated a web page for each file translated displaying its contents in an easy-to-read table, along with the results of basic integrity checks. This enabled testing of the data by users on two continents on a daily basis. When the data and algorithms were fully tested and known to be in their final shape, a fairly junior developer with six months experience wrote the eventual C++ program in under a week.
There's a Python on the Scoreboard!
A number of large sports stadiums in Australia (including the two largest with 100,000 person capacities) run custom scoreboard control software during all matches. This software is responsible for keeping and displaying the score for the game (including personal player information), and displaying other messages and advertising during the match. The information is displayed to the huge video scoreboards installed, as well as smaller strip scoreboards located around the ground and locally to the scorers PC using HTML.
The system runs on Windows NT computers, and needs to talk to a variety of custom software and hardware, including custom input device for score keeping and custom hardware to control the video and strip scoreboards. The system also needs to be able to read data during the game from an external database which provides detailed game statistics for each player.
The scoreboard software is written in C++ and Python. The C++ components of the system are responsible for keeping the match score, and maintaining the key score database. All of the scoreboard output functionality is written in Python, and exposes Python as a macro language for the scoreboard operators.
Each output device (for example, the video screen, strip scoreboard or HTML file) has a particular "language" that must be used to control the output. HTML, for example, uses <TAGS>, while the video scoreboard uses a formatting language somewhat similar to postscript. A common thread is that all output formats are text based.
A scheme has been devised that allows the scoreboard operator to embed Python code in the various layout formats. As the format is displayed, the Python code is executed to substitute the actual score. For example, the scoreboard operator may design a HTML page with code similar to
| <P>The player name is <I><%= player.Name %></I>
Anything within the <% tag is considered Python code, and the value substituted at runtime. Thus, this single HTML layout can be used to display the information for any player in the game.
The nature of Python has allowed this to provide features that would not be possible using other languages. One such feature is that the scoreboard operator is free to create new database fields for a player using Microsoft Access and use them in the scoreboard layouts immediately using player.FieldName syntax; thus the object model exposed to the user is actually partially controlled by the user. The use of Python also allows arbitrary code to be executed to control the formatting. For example, the scoreboard operator may use the following HTML to display the list of players in the home team:
|<p>Team <% = home.Name %>
|<% for player in home.Players: %>
|<P><%= player.Name %>
|<% #end %>
This has resulted in a situation programmers strive for, but see all too rarely; a system with enough flexibility that the users are able to do things with your software that you never dreamt could be done!
Other Python' Sightings in the Wild
To further dispel any impressions that Python is new, immature, or unsuited to critical applications, we've included a very small selection of projects and organizations using Python in the real world. These have been culled from a much longer list on the main Python web site., http:www.python.org/