...making Linux just a little more fun!

<-- prev | next -->

Vancouver Python Workshop 2006

By Mike Orr (Sluggo)

The second Vancouver Python Workshop took place in August in Vancouver, Canada. It was a much smaller event than PyCon, attracting 120 people to the Holiday Inn Express in suburban Burnaby, and spanning one weekend plus Friday evening. (Small Python conferences are called "workshops" because that's what the original Python conferences were called.) Most of the attendees came from the surrounding area in British Columbia, plus six from neighboring Seattle. Guido van Rossum, Jim Hugunin, and Ian Caven gave keynote speeches. There were three tracks of talks: Web applications, Python tutorials, and "everything else". Before getting into the keynotes, I'd like to mention two little highlights of the conference: Python in Brazil and the Nokia tablet PC.

Python in Brazil

Leonardo Rochael Almeida discussed Python use in Brazil. In 2002, Brazil's President Lula and his party decided to support free software. At the same time Serpo, the government's IT company, wanted to put government agencies on the Web, and was looking for a content management system (CMS). Serpo met with Zope's Paul Everett, who was in Brazil speaking at a Linux conference, and decided to use Plone. (Zope is a Web application framework written in Python; Plone is a CMS built on top of Zope.) Leonardo converted Serpo's company portal from IIS/ASP to Plone in two weeks, and a blind employee of Serpo demonstrated it at Comdex-br. Plone now powers 120 national and regional sites including Brazil's main portal, the president's site, and the Parliament's sites (the Câmara dos Deputados and the Senado). The Parliament chose Plone over Oracle, Vignette, MS SharePoint, and IBM WebSphere for its features and ease of use -- not for its price. The two sites cover parliamentary activity, the laws in force, finance, and human resources. The same system is replicated for local governments.

Another Python application is Projecto Presença, a national school attendance program that covers 206,000 public schools (and 50,000 more planned). Yes, in Brazil, Big Brother knows whether you went to school or not. Projecto Presença is a Web application written in CherryPy, SQLite, and Zope Page Templates. A Web interface was chosen because the schools have several different OSes. However, it's run standalone on local computers due to sporadic Internet availability. Through this work and the other sites, Python has gained enough credibility that it's now considered for every government programming project, and is frequently chosen.

Several other organizations in Brazil are also running Python applications, including 4FS Consulting, IDG Now, CTBC Telecom, AOL-br, Bank Boston, and Nokia. The most interesting case is a cargo tracking application. Brazil has a problem with thieves stealing delivery trucks, and truck-based GPS is useless because the thieves will just unload the cargo to a second truck and abandon the first. So now they're using a German device embedded in the cargo, which measures the proximity of local cell towers and sends an SMS message with their ID and distance to a central server, which then calculates the cargo's location.

Nokia built a research center in Brazil. ("It just happens to be located near an incredible beach.") There, Nokia ported Python to its Internet Tablet 770, which runs a derivative of Debian Linux on an ARM chip. Nokia has contributed code upstream, including "a huge number of tests" for Linux's Bluetooth stack, and optimizations to Python/ARM. They've also ported Tapioca VoIP to the device. (Tapioca has PyTapioca Python bindings). Three people at the conference had this little Nokia tablet ("It's not a phone!"), and I thought it was pretty nifty; I'm writing an article about it for the next issue.

Python 3000

Guido spoke about Python 3.0 (aka "Python 3000"), which will be available in early 2007 in alpha form, and the final a year after that. It will be a backward-incompatible version of Python, "a chance to fix early design bugs, mainly from 1990-1991, such as classic classes, the string/Unicode dichotomy, and integer division." The 2.x series will continue to be supported for 2-3 years, depending on how quickly users switch to 3.0. Some features will be backported to 2.x.

Python 3000 will have new keywords, dict.keys() and friends will return an iterator or a "set view" rather than a list, print will be replaced by function(s), the str type will be Unicode, unicode will disappear, and a new mutable bytes type will handle byte arrays (and 8-bit encoded text like UTF-8). This will necessitate a new I/O subsystem to handle the new types. All these have been decided, but it will take a good year to write the code and deal with the inevitable implementation issues. For instance, Guido wants to abandon C's stdio library for I/O, saying the differences between platforms are too cumbersome.

The bytes type will be an array of ints each in range(256). There will be some string-ish methods like .find but not blatant string methods like .upper. The "set view" mentioned above is borrowed from Java's Collection interface, which is apparently lighter weight and more versatile than iterators for some things.

Another new feature Guido is considering is overloaded functions. That is, a callable that dispatches to any one of several functions according to the caller's argument types. This would solve the problem of adaption, but in a more general way. (Adaption is making an object support a protocol, such as a "dict-like object" or a "file-like object".) Overloaded functions would mainly be used by framework writers and library writers rather than by end users.

A pychecker-like tool can probably do 80% of the work of upgrading Python programs, but the other 20% will have to be done by hand. A future version of Python 2 may have optional warnings about code that will behave differently under Python 3.

Those who want to track the changes and non-changes can see PEPs 3000-3999, Guido's blog, and the Python 3000 mailing list.

Other talks

Jim Hugunin gave a keynote on "IronPython: Python in a .NET World". Jim wrote the original Jython (Python for the Java virtual machine), and now works at Microsoft on IronPython, which compiles Python source to .NET's "Common Language Runtime" (CLR) bytecode. Programs run up to twice as fast on IronPython compared to CPython due to the CLR's extensive optimization. The CLR was originally developed for C# and Visual Basic, but has purposely been kept language neutral. MS maintains a SourceForge-type site for IronPython under a -- gasp -- BSD-like license. (Or what MS thinks is a BSD-like license; here's the license itself. Others can comment on it better than I can. [1])

Linux users who have fallen asleep at all this Microsoft babble may want to check how Mono is getting along, and see how well IronPython works with it.

Since Jim's last talk at PyCon 2005, IronPython has released an almost-1.0 version. (The final is expected later this year.) It integrates with Visual Studio, and PowerShell 1.0 will be in a future version. PowerShell is "the next generation Windows shell", combining features of a traditional Unix shell with OO-language features. Jim demonstrated how you can use PowerShell as a library from within Python:

 >>> from powershell import *
>>> shell.get_service(name="*")
[  ... prints a list of running services (daemons) ...]

You can also call other CLR libraries from Python and vice-versa, embed a Visual Basic interpreter in Python (he demonstrated it interactively), and other inter-language feats. He demonstrated calling a Visual Basic library to play a sound:

 >>> My.Computer.Audio.Play("tada.wav")

One design issue that arose is the inconsistent method names between Python and .NET. To chop whitespace off both ends of a string, Python provides s.strip(), while .NET spells it s.Trim(). Jim decided that "a Python program should behave like a Python program by default", so only s.strip() is allowed unless you execute import clr to bring in the CLR methods. Fortunately, the CLR methods are capitalized, so they don't conflict with the Python ones.

Finally Jim demonstrated Merlin, which is probably Clippy disguised as a wizard. But this Merlin responded to voice commands.

Web Track

Ian Bicking gave an introduction to WSGI, the protocol that allows Web applications from different Python frameworks to interrelate. (WSGI will soon be in the Python standard library.) Ian calls WSGI "a series of tubes", which like Unix pipes connect little special-purpose routines into a larger whole. The slides are here (ODP file; OpenOffice.org required), but the highlight was this diagram of a heterogenous Web application made up of a dozen independent units. The diagram is cool because it's colored with crayon!

David Ostrowski from Ford Research Laboratory described how he used AJAX and Jython to design automobile assembly lines. It's a complicated job to schedule all the tasks involved in assembling a car, and to load-balance them among the workers so one isn't overloaded while another is twiddling his thumbs. The program calculates in units of the time needed to complete the shortest task, and comes up with an overall time requirement for the entire operation. The existing application used an unsupported JVM + XML + AJAX. David used Python to convert Excel/VB source files into XML, and then an XSLT transformation to produce VRML, which allows operators to view a car drawing in 3-D and rotate it. A Web service converts XML to VRML for client programs. Python has now gained a lot of acceptance at Ford.

There were four talks on Plone, including a "Past, Present, and Future" panel discussion, and a talk on how to customize Plone's look. The panel said most of Plone's competitors are commercial, and it compares favorably to systems costing $20,000-200,000. Plone doesn't have many open-source competitors. Drupal is not really a competitor because it operates in a different market. (They didn't elaborate on what that meant.) Plone now has 200+ add-on products designed for it.

The Linux Gazette Editors took a look at Plone recently and were quite impressed. We'll be migrating LG to Plone over the next month. (Just kidding!) [2]

General Track and Tutorial Track

There was a talk on the status of PyPy. PyPy is a Python interpreter written in Python. (Actually it's written in a static-friendly subset of Python called RPython.) The performance overhead is now in the single digits, as opposed to 1000% slower last year. Version 0.9 is released; it passes 95% of the Python core tests. PyPy compiles to Python bytecode, and it can also compile to native C or .NET. The value of PyPy is not that users will want to run their applications on it, but that it makes an easy development environment to test enhancements to the interpreter.

Wilson Fowlie introduced PyParsing, which is like a regular expression engine but you build the ruleset using regular object constructors and methods rather than a string of ASCII symbols. Wilson is not a PyParsing developer; he's "just" a user -- somebody who found it useful in his work. Here's an example of PyParsing:

 >>> rule = Literal("The") + "quick" + "brown"
>>> rule += Word("P", "hnoty")
>>> rule.parseString("The quick brown Python")
["The", "quick", "brown", "Python", {}]

(The last rule matches any word that starts with capital "P" and contains only characters from the set "hnoty". It would also match "Pyythoon".) You can also match a word to a regex if you really want to. PyParsing can also do things regexes can't, like match opening and closing parentheses and handle nested expressions. And you can specify a key for each rule, so that the value is accessible both by index and by attribute.

Brian Quinlan introduced Avalon, MS's next-generation GUI API. He showed a Python Pong game that can change its appearance based on an XML file. Do you want your mallets to look like boxy white pixels or images of Earth and Mars at war? The XML file can also change Pong's behavior; e.g., giving the Martian a disadvantage by giving it a shorter mallet or moving it closer to the center. Beware of video games with remote-upload features, especially if you have enemies!

There were also talks on using the Macintosh's Cocoa environment, building Mac apps with py2app, and building Windows apps with py2exe. Apparently, there was a problem with the Macintosh talks changing their title and not sticking to topic, however.

The tutorial track gave an all-day introduction to Python, plus a two-hour "Plone Rapid Bootcamp". The Python tutorial was well attended (40 people), but some complained that it was too basic. That may be a lesson for next year, to define the target audience and communicate it to attendees. Programmers who are new to Python need a different kind of tutorial than those who have never programmed before. Some people know what floats and Object-Oriented programming are; others don't. Perhaps "beginning" and "intermediate" tutorials are needed.

Lightning Talks

Lightning Talks are short 5-minute talks; they've been very popular at Python conferences. The talks included:

Ian Caven

That segues into Ian Caven's closing keynote, "Python Goes to Hollywood". Ian started a small company to enhance classic movies in a film-to-digital-to-film manner using off-the-shelf Macintosh G4's. Customers expect DVD movies to look slick (bright and clear), even if the original films didn't. He started with a cluster of 18 G4's controlled by an iMac, and now has 550 G5s in a large room. ("I can't switch them on all at once. My electric bill is $5000 per week.") Initially he wrote in C/C++, but then switched to Python, using Python's Numeric package for fast matrix calculations, and Zope as a user interface on the controllers. His strategy was first to make it work, then to make it work faster/better/more featureful. Amazingly, Ian was the sole developer for several years, working with one partner. Now the company has some 24 people. It was originally called Lowry Digital Images, Inc., but is now owned by Digital Theater Systems (DTS).

Ian started with individual movies like North by Northwest and Citizen Kane and gradually got larger contracts including the Star Wars series and the James Bond series. His company has now done 150+ movies total, including most of the classic Disney cartoons that are available now.

Other Aspects

It was a busy weekend in Vancouver. Saturday night was the last installment of an annual fireworks competition, so all of Vancouver and many Pythoneers crowded on the beaches to watch Mexico's 30-minute entry, which won first prize. Sunday was Vancouver's Gay Pride march. Monday was BC Day, a provincial holiday. And given that I work with offshore oil spills, it was ironic that a spill Friday off nearby Squamish was topping the newspaper headlines.

Vancouver is an awesome city, especially if you like tall, dense, pedestrian urban environments like I do. The conference hotel was at a "suburban shopping mall", but that doesn't do it justice. The mall and the hotel and several nearby shopping centers are linked by plazas and sidewalks and over-street bridges, so you can walk from the Skytrain to any one of them without crossing a single parking lot or street. This made the hotel convenient to restaurants and downtown, and was the best conference layout I've seen anywhere.

Features I hadn't seen before that made this conference work well:

Things that didn't work so well:


The Vancouver workshop is a smaller regional variant of PyCon with some fresh ideas. It didn't cover Python core programming or have sprints, and the talks were more geared to "how to do things" talks rather than "what I'm doing" or "what this package is". I'm not sure whether this was intentional or a coincidence, but it gave the workshop a more practical feel. Some attendees complained about the quality of individual talks, and I myself found some talks not living up to what I expected from the title, but these are faults common to all new events, and things will doubtless improve if the organizers decide to continue putting on the Vancouver Python Workshop. The first workshop was two years ago; we'll wait to see if there's a third. And maybe it points the way for the "West Coast conference" and "regional conferences" some people have been clamoring for.

[1] Rick Moen comments: Your wish is my command.

Although the "Shared Source License for IronPython" has wording nothing like that of the BSD licence, its purport is nearly identical, except that (1) it includes a termination clause in the case of patent litigation, (2) it is worded in a fashion more strongly invoking the concepts of contract law, and (3) it omits the BSD licence's prohibition against using prior contributors' names to endorse or promote products. I would consider it to comply with the Open Source Definition.

[2] RM: Having administered Plone, I somehow keep hearing the words "like kicking a dead whale down a beach" in my mind.

Talkback: Discuss this article with The Answer Gang

picture Mike is a Contributing Editor at Linux Gazette. He has been a Linux enthusiast since 1991, a Debian user since 1995, and now Gentoo. His favorite tool for programming is Python. Non-computer interests include martial arts, wrestling, ska and oi! and ambient music, and the international language Esperanto. He's been known to listen to Dvorak, Schubert, Mendelssohn, and Khachaturian too.

Copyright © 2006, Mike Orr (Sluggo). Released under the Open Publication license unless otherwise noted in the body of the article. Linux Gazette is not produced, sponsored, or endorsed by its prior host, SSC, Inc.

Published in Issue 130 of Linux Gazette, September 2006

<-- prev | next -->