Exec acting like execfile

Robert Hanlin findler_lambda at yahoo.com
Tue Aug 13 23:03:37 EDT 2002

Hans Nowak <wurmy at earthlink.net> wrote in message news:<3D5885F4.4070407 at earthlink.net>...
> Quite a few people would say, "by not using exec"... :-)
> exec isn't a function, but a statement, and it can execute arbitrary code:

Yup, I understand that.  I need exec, because I want to write an IDLE
replacement, with Jython.  Then maybe I can write a tutorial about

I've got it working, it's just my workaround is to dump the user's
code to a file, and then have execfile() execute that.  Argh! ;-)

> It also supports pasisng in dictionaries for global and local variables:
>  >>> a = {}
>  >>> b = {}
>  >>> exec code in a, b

Aaah... thanks, I didn't find this in the docs!  I'll try it out.


More information about the Python-list mailing list