ANN: python4ply-1.0

Andrew Dalke dalke at
Sun Mar 9 03:08:16 CET 2008

Home page:



python4ply is a Python parser for the Python language. The grammar  
definition uses PLY, a parser system for Python modelled on yacc/lex.  
The parser rules use the "compiler" module from the standard library  
to build a Python AST and to generate byte code for .pyc file.

You might use python4ply to experiment with variations in the Python  
language. The PLY-based lexer and parser are much easier to change  
than the C implementation Python itself uses or even the ones written  
in Python which are part of the standard library. This tutorial walks  
through examples of how to make changes in different levels of the  

To give you an idea of what it can do, here are some examples from  
the tutorial:

      # integers with optional underscores separators
amount = 20_000_000
print "You owe me", amount, "dollars"

       # sytax-level support for decimals
% cat
print "float", 1.0 % 0.1
print "decimal", 0d1.0 % 0d0.1
% python -e
float 0.1
decimal 0.0

       # Perl-like match operators
for line in open(""):
     if line =~ m/def (?P\w+) *(?P\(.*\)) *:/:
         print repr($1), repr($args)

				Andrew Dalke
				dalke at

More information about the Python-announce-list mailing list