Deelan wrote:
> i just tried this from python console:
> m = __import__('socket', globals(), locals(), [])
>
> this import "socket" module a store in m. being a python newbie
> too i'm wondering is this can be used instead of exec(<python code>).
>
> __import__:
>
> '' This function is invoked by the import statement. It mainly exists
> so that you can replace it with another function that has a compatible
> interface, in order to change the semantics of the import statement. ''
>
> http://www.python.org/doc/current/lib/built-in-funcs.html
Cheetah uses __import__() I think (I'm away from home so I can't check for
sure) and it's very convenient. In spite of the docstring, it's good for
importing stuff when you have to calculate the module name. It's much
cleaner than using exec.
-- Mike Orr ([EMAIL PROTECTED])
-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss