Skip to main content

A Python source-code generator based on the ``compiler.ast`` abstract syntax tree.

Project description

Overview
========

This package provides a module-level source-code generator which
operates on the AST from the built-in ``compiler.ast`` module.

Note that this AST is not compatible with the new ``ast`` module in
Python 2.6.

Usage
-----

The generator works on AST parse trees.

>>> from compiler import parse
>>> tree = parse("""\
... print 'Hello, world!'
... """)

We can now generate Python-code equivalent to the original using the
source-code generator.

>>> from sourcecodegen import ModuleSourceCodeGenerator
>>> generator = ModuleSourceCodeGenerator(tree)
>>> print generator.getSourceCode()
print 'Hello, world!'

Author
------

Malthe Borch <mborch@gmail.com>


Changelog
=========

HEAD
~~~~

0.2 (released 27/11/2008)
~~~~~~~~~~~~~~~~~~~~~~~~~

- Fixed issue with tuples and parentheses. [malthe]

- Fixed issue with multiple assignments. [malthe]

- Added support for `not` operator. [malthe]

- Fixed issue where default arguments would be written incorrectly if
no non-keyword arguments were present. [malthe]

- Fixed issue where statements would not be cleared properly. [malthe]

- Assignments are statements and should terminate. [malthe]

0.1 (released 26/11/2008)
~~~~~~~~~~~~~~~~~~~~~~~~~

- Initial release.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sourcecodegen-0.2.tar.gz (9.9 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page