Re: eval vs. exec
will guaraldi <[email protected]>
| Newsgroups | gmane.comp.games.mud.client.lyntin |
|---|---|
| Message-ID | <[email protected]> |
On Tue, 6 Apr 2004, Eugene wrote: > On Tue, 6 Apr 2004 09:29:57 -0500 (CDT) > will guaraldi <[email protected]> wrote: > > > >I'd rather not provide an empty default lyntinuser in the modules > >directory. If you do a site installation of Lyntin, the admin would > >have to remove the lyntinuser module from the modules directory in > >order to allow users to create their own. I think that's too much of a > >runaround. > > I believe the custom module, if any, would silently override the default > one. I agree, though, the default is not needed to provide the empty > symbol dictionary. Mmm... I'm not sure that's true since sys.modules is a dict and we just iterate through the keys and there's no guarantee that a "lyntinuser" will be before a "lyntin.modules.lyntinuser" (or any other package). We pick up the first one that we get to. > >I like the warning there. It lets people know that they should be > >running their python commands in a lyntinuser module that they create. > > Oops, I've just removed it. Ok, I will put it back; but the message is > plain wrong - the code snippet is not executing in "advanced" module > context. (And why would a user want to execute a code in the "advanced" > context?) In fact, it's executed in an empty context. Put the warning > back yourself, or let me know what text it should have, and I'll put it > there. Hmm... I don't agree that it's plain wrong because the message says that it's executing in "advanced.py" and doesn't say "in the advanced module context". We create initially empty globals and empty locals dicts (they might be the same--I forget) which get reused between exec calls. Thus we maintain variables the user creates in python_cmd calls. Those dicts are stored in the advanced module. So we're not executing things in the advanced context, we're executing them in a context created in the advanced module. I'll adjust the message to make this clearer. /will ------------------------------------------------------- This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click