[CentralOH] That for Which I Use Python

William McVey wam at cisco.com
Thu Apr 19 18:19:28 CEST 2007

On Wed, 2007-04-18 at 08:00 -0400, Daniel 'Dang' Griffith wrote:
> I use Python primarily for text manipulation. Some of my first "real" work
> with it was parsing Delphi source files, and extracting various metrics
> from the code, including a call-reference map. I used the excellent
> Pyparsing framework (pyparsing.wikispaces.com), developed by Paul
> McGuire. 

Hey, cool. I'm a fellow pyparsing fan. I first used it a few years ago
to build a parser for a subset of a SQL dialect being used by the OVAL
project (before they migrated their data format to XML). Later, I ended
up using it to help in the parsing of IOS config files.

> I've experimented a little with PAMIE (pamie.sourceforge.net), a program that
> lets you use Python to control Internet Explorer. I used it to 
> develop a "proof
> of concept" for GUI-testing a web-based I was part of developing.

If the testing you want to perform is at the level of controlling IE,
then another test approach that you might want to consider (or at least
be aware of) is Selenium (http://openqa.org/selenium/). Selenium is a
Javascript application that runs in your browser (supported under IE,
Firefox, Safari, etc) that reads test definitions out of an HTML file
and uses iframes to execute the particular test. The test definitions
are able to use higher level constructs than "raw" Javascript. In fact,
you can even code your tests in python and then convert that python code
into the HTML pages that are used by the Selenium (using
make_selenium.py -
http://joker.linuxstuff.pl/documentation/make_selenium). You can also
now use python scripts to speak to Selenium Remote Control
(http://www.openqa.org/selenium-rc/) (a web application) which can end
up controlling an browser running the Selenium javascript test engine.

The great thing about Selenium over an approach like pamie is that the
same testcases you write to test IE's behaviour with your web app can be
reused to test the other browser's use as well. This includes testing
things like AJAX interactions within the browser doing the testing.

> Actually, I've done very little at all with GUI and Python. I played 
> with Tkinter
> when I started using Python, and have played with wxPython. But most of
> my work seems to not require a GUI, so I've never spent the time learning
> a library well enough for it to seem easy or natural. If anyone has used one
> enough to make a recommendation, I'd appreciate it.

Most of my GUI work has been under Linux. I like the pygnome and pygtk
libraries for GUI work (especially libglade, along with the glade
interface builder) and can generally get something that works cranked
out pretty quickly. On the other hand, it's really hard to beat the
portability and native look/feel of wxPython. I really wish it was as
easy to use as the pygnome and glade combination. I was left
dissatisfied with my experimentation with wxglade as well as Boa

> I've been working on a long-term (due to time availability) project to analyze
> a data model (using foreign key constraints to determine relationships). The
> user then specifies a set of data from a single table, and the program will
> extract the complete set of dependent data. The purpose of this would be
> to extract meaningful development/test data from databases too large to
> host in a developer's environment. Instead, meaningful and complete subsets
> could be used, instead. I have it to the point where it can parse a schema
> (exported from Oracle) and generate a simple set of SELECT queries. As with
> the PAMIE project, I have the proof-of-concept, but have not had time to
> complete the project.

Are you familar with the various ORM's that exist for python? In
particular, it sounds like your project could fairly easily be
accomplished with SQLAlchemy or perhaps Django's ORM (you'd have to use
the multiple-database-support branch if you wanted to be able to write
your subset of data to new db.)

> I just thought I'd pass that along, in case you know anyone in your 
> organization who
> could be using Python for doing things like these.

Thanks! It's always interesting to hear what other people are using
Python to do and especially the approaches they choose to solve real

  -- William

More information about the CentralOH mailing list