Thuban/UI/main.py : import problem

Bernhard Herzog bernhard.herzog at intevation.de
Tue Aug 1 19:39:32 CEST 2006


Hi,

On Tuesday 01 August 2006 18:47, Didrik Pinte wrote:
> When subclassing ThubanApplication in order to customize Thuban
> (splashscreen etc.), I'm facing a little problem of imports

If you'd like to have some example code for this, have a look at 
http://great-er.intevation.org/

[...]
> "/home/did/projets/python/thuban/trunk/thuban/Thuban/UI/application.py",
> line 37, in ?
>     import mainwindow
[...]
> line 18, in ?
>     from application import ThubanApplication
> ImportError: cannot import name ThubanApplication
[...]
> I don't understand where is the problem exactly.

There's a recursive import. Why it fails is described in some detail here:
http://effbot.org/zone/import-confusion.htm#recursive-imports

> According to PEP-8, it is best to have only absolute imports.

Absolute imports have nothing to do with this.

> Finallly, I got it to work by changing the imports and the code like
> this :

In main.py, I guess.

> < from application import ThubanApplication
>
> > import application
>
> <        app = ThubanApplication(0)
>
> >        app = application.ThubanApplication(0)

Looks good.  Could you apply this change and check it in?

> [2] What is the best way to allow the subclassing of ThubanApplication ?

I'm not sure exactly what you are asking here.  Can you elaborate a bit?

   Bernhard
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.intevation.de/pipermail/thuban-devel/attachments/20060801/94bd4ca8/attachment.bin


More information about the Thuban-devel mailing list

This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)