Path question
Diez B. Roggisch
deets at nospam.web.de
Tue Feb 3 14:22:25 EST 2009
Geert Vancompernolle schrieb:
> Hi,
>
> I have the following path construction:
>
> ./src/__init__.py
> /main.py
> /modules/__init__.py
> /application.py
> /ui/__init__.py
> /mainwindow/__init__.py
> /mainwindow.py
>
> Now I want to call the method 'MainWindow' in the module 'mainwindow',
> from the module 'application'.
>
> I'm having the following import statement in 'applications.py':
>
> from .. ui.mainwindow.mainwindow import MainWindow
>
> That doesn't work. I've also tried many other combinations like from
> ..ui.mainwindow... but none of them work.
>
> I always get the following error:
>
> "Attempted relative import beyond toplevel package"
>
> How can I import the method 'MainWindow' from 'mainwindow' into
> 'application', using the explicit relative import rules?
>
> Or is there a better way to do this?
>
Rename "src" to "myapp", and start main.py from above that. That should
work.
Diez
More information about the Python-list
mailing list