|
From: Jim A. <ji...@tr...> - 2001-04-11 00:14:47
|
Jim Adrig wrote:
>
> It looks like the 'if' statement (and 'for') can't be split across
> 'exec' statments.
>
> Neither this:
>
> python.exec("if 1:");
> python.exec(" print 'true'");
>
> nor this:
>
> python.exec("for x in range(1,2):");
> python.exec(" print x");
>
> work for me. Of course this works:
>
> python.exec("for x in range(1,2): print x");
>
> or this (multiple lines in a SINGLE 'exec':
>
> String s = "if 1: \n print 'true'";
> python.exec(s);
>
By the way, this behavior makes sense since the 'exec' statement
COMPILES the string sent to it before executing it. It must be
syntactically correct..and complete. So I doubt this will be 'fixed'..if
it's even possible.
Is there a reason you're not using 'interpreter.execfile( infile )'
instead ?
--
__o
Jim Adrig _ \<,_
ji...@tr... ' `/ ' `
___________ `-' `-'
|