A RetroSearch Logo

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

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2004-July/046229.html below:

[Python-Dev] Absolute/Relative import switcher for packages (PEP 328)

[Python-Dev] Absolute/Relative import switcher for packages (PEP 328) [Python-Dev] Absolute/Relative import switcher for packages (PEP 328)Wiktor Sadowski art at wiktorsadowski.com
Thu Jul 15 22:09:04 CEST 2004
FWIW:
Here is the solution for  Absolute/Relative problem that we are using
in our modified Python distribution...

We have added a few lines of code to to get_parent in import.c.
The code checks if there is "__absimport__=True" in parent dict
and if so: absolute import is used in "child" module (get_parent returns
Py_None)

Then putting "__absimport__=True" into an __init__.py is enough to
force absolute import for the whole package.
(The "__absimport__=True" switcher should be put into each subpackage
__init__.py,if desired)

Such addition is fully compatible with existing
Python import syntax and easy to use.

Also:
absolute import could be default,and "__relimport__=True"
would switch to relative import.

If nothing else,the switcher really helps with tracking absolute/relative
import
bugs in Python packages.

Wiktor Sadowski

More information about the Python-Dev 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