>  On 6/20/06, Patrick M. Nielsen <[EMAIL PROTECTED]> wrote:
> > for module in modules: print "Loading %s..." % module exec 'import
> > %s' % module
> >
> > Although I like the outcome of writing it like this, I don't feel
> > good about it. Is this against standard Python conventions or
> > morals? Loading modules this way, that is (instead of just
> > importing it all "the right way" and making a print statement for
> > each one).
> >
> >
Troy Melhase wrote:
>  __import__(name, globals, locals, fromlist) -> module
>
>  Import a module.

... grumble ... top posting ... grumble ... no text ...  grumble ...

(Probably) Troy's point here is that you'd be better off to use the
built-in __import__ function instead of using exec. This is probably
clearer. There is no fundamental reason why it is more secure,
though (the usual complaint about exec), because you are in
complete control of what exec is being fed.

However, I'd still recommend __import__ for clarity.

Cheers,
Terry


-- 
Terry Hancock ([EMAIL PROTECTED])
Anansi Spaceworks http://www.AnansiSpaceworks.com

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to