Basic 'import' problem

Frantisek Fuka fuka at
Sun Feb 8 00:02:19 CET 2004

Josiah Carlson wrote:

> If the thread were up on google, I'd link it, a thread started with the 
> subject of "software design question".
> What you want can be done in two ways.  Quoting myself from that thread, 
> there's the kludge:
> main = someclass()
> import sys
> sys.modules['external'].main = main
> And there's the standard method:
> import module1
> ...
> class main:
>     def __init__(self, args...):
>         self.c1 = module1.class1(args...)
>         #where args... is the standard initialization for your class,
>         #              and any additional objects/methods that c1 needs
>         #              access to.
> Pass what is needed.  If you can't pass what is needed when external 
> module classes are initialized, then set the attribute later.
> c1instance.attribute = value

Thanks for that. It makes sense.

Now, if imports and imports, does this present any 
fundamental problems? (e.g. something get initizlized twice...)

                                          Frantisek Fuka
(yes, that IS my real name)
(and it's pronounced "Fran-tjee-shek Foo-kah")
My E-mail:   fuka at
My Homepage:
My ICQ:      2745855

More information about the Python-list mailing list