[CentralOH] That for Which I Use Python

Daniel 'Dang' Griffith pythondevdang at lazytwinacres.net
Wed Apr 18 14:00:33 CEST 2007

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. (Interesting anecdote:after a few emails to/from Paul, we discovered
that we both attended university at Rensselaer Polytechnic Institute,
although he had graduated by the time I started.)

I'm currently using it to analyze Microsoft SQL Server TSQL code, as
part of an effort to migrate it into Oracle PL/SQL. If you ever want a
regular expression that can suck your Oracle procedure declarations out
of a package or procedure, including the name, parameters, and their types,
just let me know. I haven't used Pyparsing on this effort, and I'm 
not sure why.
Probably because there is too much grammar for me to define, and it has
seemed that simply processing a line at a time is working (thank goodness the
source files are consistently formatted).

I've written an RPN calculator that supports input of binary, hex, and decimal,
and ASCII; supports multiplier suffixes of e, pi, k (kilo), m (mega), 
g (giga), and t (tera);
and displays the results in hex and if the value is within range, 
ASCII. It supports
trig functions, binary manipulations, and so on. It's no big deal, 
but it's kind of neat
to head a presentation on IPv6, and being able to enter "rpn 2 128 
**" and have it
spit back out 0.34 duodecilion (well, it doesn't spit *that* out--it 
spits out the 39-digit

I've written a program that analyzes PowerBuilder source files (exported from
the PBL), and produces a cross reference of stored procedure calls. Well, the
stored procedures that are called from code, not from DataWindow queries.

I wrote a mind-numbingly simple program to help someone remember things
by rote. This started from a C version I wrote maybe 15years ago when a
friend and I were taking a Japanese language course, when we both lived
in California. I moved out of state, and we don't communicate as often as we
should, but out of the blue, last year, he asked if I had such a program he
could run on his Mac. It was a quickie, and fun as well. It worked 
the first time,
once he added a line to tell the Mac where to find the Python interpreter.

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. But PAMIE
is a little too low-level to just hand off to our test team (or even 
most of our
developers).  I was in the process of writing a wrapper, that would use the
terminology we used on the project, instead of the IE-specific and DOM-based
terms, but then I was assigned other work, and never finished it. If anyone is
interested in controlling IE, PAMIE is worth considering.

I've also done some tinkering with Jython, but I've not embedded it in an
Oracle database, or anything fancy. I just used it to experiment with
interactively developing a Java GUI, without needing a fully compiled
program just to open a window.

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.

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.

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.

Have a nice day!

More information about the CentralOH mailing list