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
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