import namespace issues

Roman Suzi rnd at onego.ru
Tue Jul 10 05:48:36 EDT 2001


On 10 Jul 2001, Harald Kirsch wrote:

> THE PROBLEM:
> I have to separate a module's function into two .py-files. Now I would
> like to import both in a way that they behave like they are one file.

Strange. If functions are so closely related, their place is in 
one module.

After I read what you've written below, I concluded that probably you need
to rethink your modules' decomposition to have less dependent modules. For
example, create the third module and put low-level routines there
second.py and first.py will import from lowlevel.py and be happy.

I see no real reason this can't be done.
 
> FIRST TRY:
> Suppose the files are called first.py and second.py. I put a
> 
>   from second.py import *

from second import *
BTW

> 
> into first.py. This does not work as necessary since functions in
> second.py don't find functions defined in first.py. Same story when
> using __import__().
> 
> FINDINGS:
> What I gathered from experiments is that even with `from ... import'

Sincerely yours, Roman A.Suzi
-- 
 - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru -
 





More information about the Python-list mailing list