This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Patrick Maupin
Recipients J Richard Snape, Patrick Maupin, brett.cannon, docs@python, eric.snow, flatsieve, ncoghlan
Date 2015-10-05.21:05:41
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1444079142.05.0.394464571167.issue25294@psf.upfronthosting.co.za>
In-reply-to
Content
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 you don't have this issue with absolute "from ... import" statements is due to some special-casing in the import logic that doesn't help the other kind of import statement.)

But PEP 8 denigrates relative imports, and then goes on to describe the use of the "import x.y.z; x.y.z.foo" form as a way to avoid name clashes.

So PEP 8 promotes absolute imports, and then it presents using "import" instead of "from ... import" as a solution to some problems.  It never mentions that the 'as' clause could also solve those problems, and also never mentions that "import x.y.z" can actually cause problems in some cases.

And the importlib documentation is also a bit sparse on where things can fail.

We're in agreement that it will be difficult to document properly, and maybe I overstated my case, but my opinion remains that the current documentation promotes practices that _will_ sometimes get people in trouble.
History
Date User Action Args
2015-10-05 21:05:42Patrick Maupinsetrecipients: + Patrick Maupin, brett.cannon, ncoghlan, docs@python, eric.snow, flatsieve, J Richard Snape
2015-10-05 21:05:42Patrick Maupinsetmessageid: <1444079142.05.0.394464571167.issue25294@psf.upfronthosting.co.za>
2015-10-05 21:05:42Patrick Maupinlinkissue25294 messages
2015-10-05 21:05:41Patrick Maupincreate