[Python-Dev] a Python interface for the AST (WAS: DRAFT: python-dev...)
Brett Cannon
bcannon at gmail.com
Wed Nov 23 03:32:59 CET 2005
On 11/22/05, Neal Norwitz <nnorwitz at gmail.com> wrote:
> On 11/22/05, Brett Cannon <bcannon at gmail.com> wrote:
> >
> > But if I had my way I think that having all AST objects be PyObjects
> > and then providing support for all three ways of getting access to the
> > AST (command-line, sys iterable, function for specific code object)
> > would be fantastic.
>
> There needs to be a function that takes a filename (or string of code)
> and returns an AST.
"Yes" and "I guess". =) I can see the filename to check a module
useful for stuff like PyChecker. But for a string of code, I don't
think it would be that critical; if you provide a way to get the AST
for a code object you can just pass the string to compile() and then
get the AST from there.
> Hmm, it would be nice to give a function a module
> name (like from an import statement) and have Python resolve it using
> the normal sys.path iteration.
>
Yep, import path -> filename path would be cool.
-Brett
More information about the Python-Dev
mailing list