imports in __init__.py

Peter Otten __peter__ at web.de
Fri Dec 18 12:40:00 EST 2009


Phil wrote:

> I wrote my last message late last night. When I said "I am unable to
> import a module from the package without an import error.", I did mean
> the 'modulename' module.
> 
> However, I just set up a Debian VM with Python 2.5.2 and what I was
> trying to do works. So it is either something that changed with Python
> 3.1.1, or a problem with Windows.

In Python 3.x absolute import is on by default. Change

from application import *

to

from .application import *

to indicate that the application module is located within the current 
package.

Peter




More information about the Python-list mailing list