eval vs. exec

Simon Budig Simon.Budig at unix-ag.org
Mon May 27 15:46:54 EDT 2002


Michael Hudson <mwh at python.net> wrote:
> Hmm.  Maybe compile as "single" but smash the last PRINT_EXPR into a
> RETURN_VALUE?  Might work.  You'd probably want to turn all but the
> last PRINT_EXPR into POP_TOPs too...
> 
> Something like this?
[...]
>>>> super_eval("a = 2")
>>>> super_eval("3*4")
> 12
>>>> super_eval("a = 2; b = 3; a*b")
> 6

Whow, this is impressive. Yes, this seems to work although this is
way beyond my python-scope  :-)

I am not sure if I want to do this or if the interception of
sys.stdout is a more - uhm - Simon-friendly solution...    ;-)

Thanks!
        Simon

-- 
      Simon.Budig at unix-ag.org       http://www.home.unix-ag.org/simon/



More information about the Python-list mailing list