there was a mistake in my prev mail.. it is not able to successfully import the module.
abcde is in directory /home/mark/work/proj1, but it is looking for it in /home/mark from where i am running the script.. though i changed cwd using os.chdir() function > File "/home/mark/app.py", line 5, in <module> > import abcde > ImportError: No module named abcde On Mon, Apr 21, 2008 at 2:46 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Hi > I have a function data['function'], that I need to import from a file > data['module'], in the directory data['cwd'] > > If I do this from python interactive shell (linux fedora core 8) from > dir /home/mark it works fine: > > cwd = data['cwd'] > os.chdir(cwd) > print os.getcwd() > module = __import__(data['module']) > function = getattr(module, data['function']) > > But if I put this in a file /home/mark/work/common/funcq.py and run it > from /home/mark, it throws me error like this.. how to fix this? it > imports the module successfully, but it is not looking for subsequent > modules in the os.getcwd().. > > /home/mark/work/proj1 > Traceback (most recent call last): > File "/home/mark/work/common/funcq.py", line 60, in <module> > if __name__ == '__main__':do() > File "/home/mark/work/common/funcq.py", line 33, in do > module = __import__(data['module']) > File "/home/mark/app.py", line 5, in <module> > import abcde > ImportError: No module named abcde > -- http://mail.python.org/mailman/listinfo/python-list