Accueil
Rechercher:
sur developpez.com sur les forums
Forums | Tutoriels | F.A.Q's | Participez | Hébergement | Contacts
Accueil Conception Java DotNET Visual Basic  C  C++ Delphi Eclipse MS-Office SQL & SGBD Oracle  4D  Business Intelligence
Club Emploi Blogs   TV   Dév. Web PHP XML Python Autres 2D-3D-Jeux Sécurité Windows Linux PC Mac
FORUM PYTHON F.A.Q PYTHON TUTORIELS PYTHON SOURCES PYTHON OUTILS PYTHON LIVRES PYTHON
31.1 The basic interface

31.1 The basic interface

The top-level of the package defines four functions. If you import compiler, you will get these functions and a collection of modules contained in the package.

parse( buf)
Returns an abstract syntax tree for the Python source code in buf. The function raises SyntaxError if there is an error in the source code. The return value is a compiler.ast.Module instance that contains the tree.

parseFile( path)
Return an abstract syntax tree for the Python source code in the file specified by path. It is equivalent to parse(open(path).read()).

walk( ast, visitor[, verbose])
Do a pre-order walk over the abstract syntax tree ast. Call the appropriate method on the visitor instance for each node encountered.

compile( source, filename, mode, flags=None, dont_inherit=None)
Compile the string source, a Python module, statement or expression, into a code object that can be executed by the exec statement or eval(). This function is a replacement for the built-in compile() function.

The filename will be used for run-time error messages.

The mode must be 'exec' to compile a module, 'single' to compile a single (interactive) statement, or 'eval' to compile an expression.

The flags and dont_inherit arguments affect future-related statements, but are not supported yet.

compileFile( source)
Compiles the file source and generates a .pyc file.

The compiler package contains the following modules: ast, consts, future, misc, pyassem, pycodegen, symbols, transformer, and visitor.

See About this document... for information on suggesting changes.
Responsable bénévole de la rubrique Python : Guillaume Duriaud - Contacter par EMail :
Vos questions techniques : forum d'entraide Python - Publiez vos articles, tutoriels et cours
et rejoignez-nous dans l'équipe de rédaction du club d'entraide des développeurs francophones
Nous contacter - Copyright © 2000-2008 www.developpez.com - Legal informations.