A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2005-September/325491.html below:

import problems in packages

import problems in packagesPeter Otten __peter__ at web.de
Wed Sep 28 14:55:07 EDT 2005
Stéphane Ninin wrote:

> Also sprach Stéphane Ninin :

Sollte es denn möglich sein! Dieser alte Heilige hat in seinem Walde noch
Nichts davon gehört... that intra-package import takes precedence over
absolute import!

> Here is the basic structure of the code (I have reduced it first).

And nicely so. Not letting similar names for modules, packages and classes
abound might have been a good idea, too.

> I have an ImportError problem, which is probably correct,
> but I do not understand it. And how to fix it...

> ROOT:
> /main.py
> /Handlers/__init__.py (empty)
> /Handlers/Handlers.py
> /Handlers/HandlerFactory.py
> /Handlers/Default/__init__.py (empty)
> /Handlers/Default/Handlers.py
> /Handlers/Default/HandlerFactory.py

> ROOT/main.py contains:
> from Handlers.HandlerFactory import HandlerFactory

works and triggers

> ROOT/Handlers/HandlerFactory.py contains:
> import Handlers.Default.HandlerFactory

which tries to import

ROOT/Handlers/Handlers/Default/HandlerFactory.py, but unfortunately
ROOT/Handlers/Handlers[.py] is not a package and therefore doesn't contain
a Default package. Currently, when you have

amodule.py
apackage/amodule.py
apackage/anothermodule.py

and try to import amodule into anothermodule, there is no way to tell Python
that you mean amodule.py and not apackage/anmodule.py.

Peter




More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4