/Lib/compiler/__init__.py

http://unladen-swallow.googlecode.com/ · Python · 29 lines · 23 code · 1 blank · 5 comment · 0 complexity · 2ff7dd90ff8fb557a1607ed3a6df00eb MD5 · raw file

  1. """Package for parsing and compiling Python source code
  2. There are several functions defined at the top level that are imported
  3. from modules contained in the package.
  4. parse(buf, mode="exec") -> AST
  5. Converts a string containing Python source code to an abstract
  6. syntax tree (AST). The AST is defined in compiler.ast.
  7. parseFile(path) -> AST
  8. The same as parse(open(path))
  9. walk(ast, visitor, verbose=None)
  10. Does a pre-order walk over the ast using the visitor instance.
  11. See compiler.visitor for details.
  12. compile(source, filename, mode, flags=None, dont_inherit=None)
  13. Returns a code object. A replacement for the builtin compile() function.
  14. compileFile(filename)
  15. Generates a .pyc file by compiling filename.
  16. """
  17. from warnings import warnpy3k
  18. warnpy3k("the compiler package has been removed in Python 3.0", stacklevel=2)
  19. del warnpy3k
  20. from compiler.transformer import parse, parseFile
  21. from compiler.visitor import walk
  22. from compiler.pycodegen import compile, compileFile