get return or locals from "exec" str in "environment"

Chris Angelico rosuav at gmail.com
Thu Aug 30 20:13:52 EDT 2012


On Fri, Aug 31, 2012 at 9:54 AM, lucas <sjlukacs at gmail.com> wrote:
> oh, yeah that was perfect.  got it working and it is graceful too.  sorry about the double post, i thought i was only posting to this one.

Hehe, you're still posting to both. I don't see the duplicates myself,
but I'm sure others do. Just pick one and ignore the other.

> one final concern, if this code is running under a function in a multi-threaded, multi-session kind of environment, does exec cross threads or sessions?  like, i am afraid that i will get cross-over or bleeding into other threads or sessions.  does exec do that kind of common memory space wherein i have to be very very careful about executing such code and my daemon crashing or security holes and the like.

Not that I am aware of, and I would be extremely surprised if there
were any. But exec is not the sort of thing you'll normally want to
use. What are you trying to accomplish? There's usually an
alternative.

The only time I've used an exec-like feature is when I'm actually
writing something that loads code from the disk at run-time, such as
my MUD with room files that look like this:

@sdesc Short Description
@ldesc This is the long description of the room, blah blah
@cmds thwap #do_something_when_user_types_thwap()

VERY unusual sort of thing to do - having real code in a data file.

ChrisA



More information about the Python-list mailing list