[Ironpython-users] getting a PythonAst from a string containing Python code in c#

Venkatesh Potluri venky.92 at gmail.com
Tue Apr 4 09:10:35 EDT 2017


Hi list,

I am trying to get an IronPython.Compiler.Ast.PythonAst from a c#
string containing some python code. How do I go about doing this in
c#?

My understanding is that I first have to create a parser using
IronPython.Compiler.Parser.CreateParser() and then parse the code to
get a PythonAst.

However, I am not sure of the correct arguments required for the
CreateParser() call, the SourceUnit required for a CompilerContext,
etc.

Also, the parser has a method ParseFile() that returns a PythonAst. Is
there a way to parse a c# string containing the python code and get a
PythonAst?

I am new to IronPython so am not sure if I am missing something here.

Thanks in advance.
Best regards,
Venkatesh


More information about the Ironpython-users mailing list