On Sat, May 7, 2011 at 4:02 AM, dmitrey <dmitre...@gmail.com> wrote: > hi all, > I try to port my code to Python 3 and somehow files don't see files > from same directory, so I have to add those directories explicitly, > e.g. > import sys > sys.path += [...] > > Also, it leads to bugs like this one: > http://groups.google.com/group/comp.lang.python/browse_thread/thread/961a90219a61e19d# > > any ideas what's the reason and how to fix it? > I have tried to search google but got nothing yet.
Implicit relative imports were removed in Python 3 to prevent ambiguity as the number of packages grows. See PEP 328. If you have two modules in the same package, pack1.mod1 and pack1.mod2, then in pack1.mod1 you can no longer just do "import mod2" or "from mod2 import foo". Either use an absolute import ("from pack1.mod2 import foo") or make the relative import explicit ("from .mod2 import foo" -- note the ".") If you're upgrading scripts from Python 2 to Python 3, you should really run them through the 2to3 tool. I believe this is one of the many things it will fix for you automatically. -- http://mail.python.org/mailman/listinfo/python-list