[IPython-user] [IPython-dev] Testing help needed with IPython1
Fri Jun 22 16:48:21 CDT 2007
On 6/22/07, Stefan van der Walt <firstname.lastname@example.org> wrote:
> On Fri, Jun 22, 2007 at 02:08:00PM -0600, Fernando Perez wrote:
> > And if anyone on the list happens to be an expert on the internals of
> > how Python's AST code is supposed to work (this stuff is more or less
> > undocumented, except for the AST construction code itself), please let
> > us know. It might come handy to know we have an expert on this topic
> > 'on call', since the debugging for this stuff has been, ahem, 'fun'.
> I am curious -- how are you guys planning to use the AST? Creating an
> AST tree from source code is one thing, but can a person reconstruct
> code from an AST tree for execution?
We're not planning, we're using it :) This comes from code
contributed by R. Kern recently, and it allows us to properly compute
from source input what multiline input blocks should be considered
'units' for execution. Today's ipython has the limitations inherited
from code.py, which tries to guess when an input sequence is finished
via some finicky conventions on trailing blank lines. By building the
AST, we can properly identify the split points, so that multiline
input can be fed with arbitrary whitespace just like in a normal file,
and IPython won't choke.
After using the AST for splitting, we feed each chunk of original
source to the compiler for real compilation and execution. All of
this is in saw, in the core/interpreter.py file, if you're curious.
More information about the IPython-user