__import__ with dict values

alex goretoy aleksandr.goretoy at gmail.com
Thu Mar 12 06:43:36 EDT 2009


yay, no more

exec ("import " + "sys")

in my code

-Alex Goretoy
http://www.goretoy.com



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

> 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/143bf617/attachment-0001.html>


More information about the Python-list mailing list