[issue25294] Absolute imports fail in some cases where relative imports would work

2015-10-06 Thread Nick Coghlan
Nick Coghlan added the comment: We seem to be talking past each other, so let's take a step back and ensure we have a common understanding of the absolute/relative terminology: "import x.y.z" is an absolute import "from x.y import z" is still an absolute import. "from . import z" is an

[issue25294] Absolute imports fail in some cases where relative imports would work

2015-10-06 Thread Nick Coghlan
Nick Coghlan added the comment: (Oops, it seems Brett already clarified the terminology. My apologies for the noise). Modularity and module design is hard. It's one of the hardest problems in software engineering, which is why folks invent entire new vocabularies to attempt to describe the

[issue25294] Absolute imports fail in some cases where relative imports would work

2015-10-05 Thread Brett Cannon
Brett Cannon added the comment: You have to realize, Patrick, that the ability for `from ... import ...` to work in some situations that `import ...` won't is an age-old problem -- they are different at the bytecode level as well as how __import__ handles them -- and starting in Python 3.5 it

[issue25294] Absolute imports fail in some cases where relative imports would work

2015-10-05 Thread Patrick Maupin
Patrick Maupin added the comment: You are correct that I have conflated two issues, but they are not orthogonal -- if you choose to use relative imports, you will never encounter this issue, because your imports will all be of the 'from ... import' form. (And, as you point out, the fact that

[issue25294] Absolute imports fail in some cases where relative imports would work

2015-10-05 Thread Patrick Maupin
Patrick Maupin added the comment: concurrent/futures/__init__.py may be a better example than 2to3 for this issue. It's relatively new code, it's part of the standard library, it's fairly small and self-contained, and it doesn't follow the promulgated standard. If it's bad code, it should be

[issue25294] Absolute imports fail in some cases where relative imports would work

2015-10-05 Thread Patrick Maupin
Patrick Maupin added the comment: I don't think anything is wrong with that code. But PEP 8 prescribes a way of doing something that often won't work (which is unusual for PEP 8), with no discussion of this fact. > I think the key thing to take away from this whole discussion is "don't have

[issue25294] Absolute imports fail in some cases where relative imports would work

2015-10-05 Thread Brett Cannon
Brett Cannon added the comment: I don't quite follow what you think is wrong with https://hg.python.org/cpython/file/tip/Lib/concurrent/futures/__init__.py . It looks totally fine to me. And I should mention that you shouldn't follow PEP 8 like it's in stone and the only way to format code.

[issue25294] Absolute imports fail in some cases where relative imports would work

2015-10-03 Thread Nick Coghlan
Nick Coghlan added the comment: Issue 992389 is the previous incarnation of this bug report, while issue 17636 made the change so that from imports will resolve in some situations where this error will occur. That fact that "from x.y.b import foo" may now resolve in cases where "import

[issue25294] Absolute imports fail in some cases where relative imports would work

2015-10-03 Thread Patrick Maupin
Patrick Maupin added the comment: The PEP 8 recommendation to "use absolute imports" is completely, totally, unambiguously meaningless absent the expectation that packages refer to parts of themselves. And it works, too! (For a single level of package.) As soon as packages are nested, this

[issue25294] Absolute imports fail in some cases where relative imports would work

2015-10-03 Thread Nick Coghlan
Nick Coghlan added the comment: If that's the concern, then the relevant guidance is to avoid running code at package import time (which many new developers will now do by default with __init__.py becoming optional). -- ___ Python tracker

[issue25294] Absolute imports fail in some cases where relative imports would work

2015-10-03 Thread Patrick Maupin
Patrick Maupin added the comment: I'm a big fan of stitching things together at the top myself -- maybe that's partly an unconscious reaction to this very issue. But I'm not sanguine about how easy it is to express this practice in the docs. This issue arose in the context of me answering a

[issue25294] Absolute imports fail in some cases where relative imports would work

2015-10-02 Thread Berker Peksag
Changes by Berker Peksag : -- nosy: +brett.cannon, eric.snow, ncoghlan ___ Python tracker ___

[issue25294] Absolute imports fail in some cases where relative imports would work

2015-10-02 Thread J Richard Snape
Changes by J Richard Snape : -- nosy: +J Richard Snape ___ Python tracker ___ ___