Re: Relative import from script with same name as package

2011-08-14 Thread Oktay Şafak
14.08.2011 21:48, OKB (not okblacke) yazmış: =?UTF-8?B?T2t0YXkgxZ5hZmFr?= wrote: It appears that Python is reading "import thetest" as importing thetest.py (the same file that is currently being run). When it tries to run that file a second time, the relative import fails

Re: Relative import from script with same name as package

2011-08-14 Thread OKB (not okblacke)
=?UTF-8?B?T2t0YXkgxZ5hZmFr?= wrote: >> It appears that Python is reading "import thetest" as >> importing >> thetest.py (the same file that is currently being run). When it >> tries to run that file a second time, the relative import fails. >> > > No, there is no such thing

Re: Relative import from script with same name as package

2011-08-14 Thread Oktay Şafak
14.08.2011 00:39, OKB (not okblacke) yazmış: I'm using Python 2.6.5. I have a directory structure like this: thetest/ __init__.py thetest.py theother.py __init__.py is an empty file. theother.py contains a function foo(). The package is accessible from sys.path

Re: Relative import from script with same name as package

2011-08-13 Thread Chris Angelico
On Sun, Aug 14, 2011 at 12:55 AM, OKB (not okblacke) wrote: > sys.path = sys.path[1:] + [''] > > (That is, move the current directory to the end of the search path > instead of the beginning.) > Or, equivalently: sys.path.append(sys.path.pop(0)) ChrisA -- http://mail.python.org/mailman/listinf

Re: Relative import from script with same name as package

2011-08-13 Thread OKB (not okblacke)
OKB (not okblacke) wrote: > But why? That __future__ import is supposed to make > absolute > imports the default, so why is "import thetest" importing > thetest.py instead of the package called thetest? The absolute > import should make it look in sys.path first and not try to

Relative import from script with same name as package

2011-08-13 Thread OKB (not okblacke)
I'm using Python 2.6.5. I have a directory structure like this: thetest/ __init__.py thetest.py theother.py __init__.py is an empty file. theother.py contains a function foo(). The package is accessible from sys.path, so that if I open the interpreter and do "