__import__ with dict values

alex goretoy aleksandr.goretoy at gmail.com
Thu Mar 12 06:42:23 EDT 2009


I have resolved this problem in my code. It has something to do with your
current working directory when you append cwd/jars to sys.path and try to
import from interactive console
-Alex Goretoy
http://www.goretoy.com



On Thu, Mar 12, 2009 at 4:58 AM, alex goretoy
<aleksandr.goretoy at gmail.com>wrote:

> How would I import with __import__ from dict values?
> I want sys.path value inside d['syspath'], below code doesn't work for me
>
>
> d={}
> d['sys']='sys'
> d['path']='path'
>
> d['syspath']=__import__(d['sys'],fromlist=[d['path']])
>
> and how come does  above line doesn't give me diff value than below line?
>
> d['syspath']=__import__(d['sys'])
>
> Meaning, when I do this doesn't work. Which makes sense.
> d['syspath']()
> d['syspath'].d['path']
>
> but this works both with fromlist and without.
>
> d['syspath'].path
>
>
> -Alex Goretoy
> http://www.goretoy.com
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090312/3eb7b81b/attachment-0001.html>


More information about the Python-list mailing list