A RetroSearch Logo

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

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2004-April/044081.html below:

[Python-Dev] Re: PEP 328 -- relative and multi-line import

[Python-Dev] Re: PEP 328 -- relative and multi-line import [Python-Dev] Re: PEP 328 -- relative and multi-line importNeil Schemenauer nas-python at python.ca
Mon Apr 5 13:51:17 EDT 2004
On Mon, Apr 05, 2004 at 01:36:24PM -0400, Aahz wrote:
> Your intuition is wrong.  From package's __init__.py, ``from .`` refers
> to package's parent; to get back into the package, you need to use
> ``from .package``.

That's confusing.  I expected '.' to refer to the current package,
just as '.' refers to the current directory in most file systems.  I
think that meaning would be more useful in practice as well.
Imagine a package where '.' means the current package:

    # __init__.py ###################################
    from .a import A
    from .b import B
    #################################################


    # a.py ##########################################
    from .utils import x, y

    class A:
        ...
    #################################################


    # b.py ##########################################
    from .utils import x, z

    class B:
        ...
    #################################################

    # utils.py ######################################
    def x():
        ...
    def y():
        ...
    def z():
        ...
    #################################################


Notice that the modules that make up the package do not need to know
what the package is called.  That was one of the major benefits of
relative imports that I was looking forward to.

Perhaps I misunderstand the PEP.

  Neil

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