Amit's Python Stuff

I've been using Python for several small projects, and I've organized some of my code into reusable libraries. Most of the code, however, is still a mess.

Below are links to some of the libraries and programs I've written.

Yapps parser generator
Yapps is an easy to use parser generator that produces readable recursive descent parsers. It's not as powerful or as fast as other Python parser generators, but it's nice for smaller projects.
Mailing List formatter
Yes, I realize Pipermail can organize mailing lists. However, I wanted to learn some more Python, so I redid things differently. This script is used to format saved USENET postings as HTML. I've also included some example output. It's just a "quick and dirty" script, and would be better if each message was an object and kept track of its relationship to other messages.
MOO-style Messages
For POO, I wrote a module that parses and processes messages with %-codes in them. This module is useful when you have:
  1. Multiple users who should see text from a different point of view: For example, "%Nn %n:(waves) to %dn" will show "You wave to Joe" to Amit, "Amit waves to you" to Joe, and "Amit waves to Joe" to everyone else.
  2. Messages that involve gender and pronouns: For example, "%Ns %n:(waves) %np hand" will show "You wave your hand" in second person, "She waves her hand" in third person singular feminine, and "He waves his hand" in third person singular masculine. You can create your own gender/person combinations as well.
  3. Text that depends on singular and plural: For example, you might want to print "1 apple" or "2 apples", but you don't want to put in the ugly "if" statement to handle this. Using the message system lets you avoid some of the pain of getting number right.

The syntax for %-codes was taken from JHCore, a database for LambdaMOO systems. The message module is now used in DOOP, a distributed server project in Python which will have as its initial application a distributed MOO, but really can be used for other distributed systems as well.

MOO and Perl also have some code for generating plurals. Maybe someday I'll work on a Python version of the pluralizing algorithm.

ASCII Formatting
Also for POO, I wrote a module that can format text with word-wrapping, nested tables, lines, and spaces. This module was written for MOO and then translated into Python. I find this for nicely formatting ASCII email messages, too.
Filtering Proxy
As part of my research, I worked on a proxy that added security constraints to Java applets. I later added other sorts of document modifying filters, such as removing cookies, blocking banner ads, rewriting URLs, and even changing Slashdot from green on white to blue on gray.
Unified Namespace Proposal
Namespaces show up everywhere in Python. Scoping, classes, objects, and modules have similar underlying semantics (mapping names to values, and chaining to other namespaces). However each of them has its own little quirks. By unifying the four, we gain consistency, simplify implementation, and gain new constructs for free.

When I wrote the code above, I was still experimenting with Python style and documentation conventions. If you read the code above, you will see a definite lack of consistency.