Relative Imports, why the hell is it so hard?

Istvan Albert istvan.albert at gmail.com
Tue Mar 24 23:32:52 EDT 2009


On Mar 24, 9:35 pm, Maxim Khitrov <mkhit... at gmail.com> wrote:

> Works perfectly fine with relative imports.

This only demonstrates that you are not aware of what the problem
actually is.

Try using relative imports so that it works when you import the module
itself. Now run the module as a program. The same module that worked
fine when you imported it will raise the exception:

ValueError: Attempted relative import in non-package

when running it on its own.

Istvan



More information about the Python-list mailing list