__import__ problem

2008-12-06 Thread Kottiyath
Hi all,
   When I try to import a module via __import__, I am facing
ImportError. But, when I tried to import it via usual 'import', it
worked fine.
  Please see below:
try:
import exact
except:
logging.exception('Error during importing')

try:
code = __import__('exact')
except:
logging.exception('Is it still happening?')

  The error is as:
2008-12-06 20:06:59,328 ERROR Is it still happening?
Traceback (most recent call last):
  File "C:\django\test\..\test\basic\views.py", line 166, in getValue
code = __import__('exact')
ImportError: No module named exact

  Could you please let me know why this is happening? I tried to
__import__ 'sys etc, and it worked fine. Is it due to some issue in
the path?

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


gdesklets __import__ problem

2006-01-03 Thread Thomas Dybdahl Ahle
Hi, I'm writing a gdesklets control, that dynamicly uses __import__ and
getattr to get the right classes based on userinput. The problem is, that
my control is somehow being run from somewhere unknown. This means that
__import__ can't find the modules. I tried putting an
os.chdir("~/.gdesklets/Controls/1136298021.06/...") just before the
__import__ call, and that worked, but ofcource isn't very smart in the run.

Is there any way to find out where the control is put on the disk, so that
I can change to the correct folder? Or is there some hack, that allows me
to import the modules without knowing there location?

-- 
Programmers should realize their critical importance and responsibility in a
world gone digital. They are in many ways similar to the priests and monks of
Europe's Dark Ages; they are the only ones with the training and insight
to read and interpret the "scripture" of this age.

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