importing modules with the same name but from different directories
koenig at v-i-t.de
Mon Apr 21 14:50:01 CEST 2003
On Mon, 21 Apr 2003 04:42:51 +0200, logistix wrote:
>> -----Original Message-----
>> From: python-list-admin at python.org
>> [mailto:python-list-admin at python.org] On Behalf Of Mirko Koenig Sent:
>> Sunday, April 20, 2003 9:26 PM
>> To: python-list at python.org
>> Subject: importing modules with the same name but from different
>> I have a program consisting of many modules. Every modul has its own
>> directory in a directory called modul, eg.
>> In every modul directory is a diretory for the language files. These
>> files are used to display the modules label in different languages. eg.
>> My problem is:
>> If is start modul1 from within its modul directory ( .../modules/modul1
>> ) And modul1 calls modul2, then modul2 doesn't load its own language
>> file. Instead it loads the langugae file of modul1.
> Add an __init__.py file to each directory in your project. This makes
> the directories packages. Then you can use a fully qualified path such
> as "import modules.modul1.language.english as module1_english". Note
> that you can't use the same name for different modules at runtime, so
> use "as xxx." to give them a more distinct name.
Is it possible to to something like this:
from modules.modul1 import *
from modules.modul1.language.english import text as modul1_text
import modules.modul1 as modul1 and than get the languag file
More information about the Python-list