[Python-Dev] question/comment about documentation of relative imports

2010-10-05 Thread Darren Dale
I have a couple questions/comments about the use of PEP 328-style relative imports. For example, the faq at http://docs.python.org/py3k/faq/programming.html#what-are-the-best-practices-for-using-import-in-a-module reads: Never use relative package imports. If you’re writing code that’s in the

Re: [Python-Dev] question/comment about documentation of relative imports

2010-10-05 Thread Simon Cross
On Tue, Oct 5, 2010 at 4:56 PM, Darren Dale dsdal...@gmail.com wrote:   from ...sys import path   Note that while that last case is legal, it is certainly discouraged (insane was the word Guido used). Only if by legal you mean happened to work. It stops happening to work in Python 2.6.6. :)

Re: [Python-Dev] question/comment about documentation of relative imports

2010-10-05 Thread Michael Foord
On 05/10/2010 17:13, Simon Cross wrote: On Tue, Oct 5, 2010 at 4:56 PM, Darren Daledsdal...@gmail.com wrote: from ...sys import path Note that while that last case is legal, it is certainly discouraged (insane was the word Guido used). Only if by legal you mean happened to work. It

Re: [Python-Dev] question/comment about documentation of relative imports

2010-10-05 Thread Antoine Pitrou
On Tue, 05 Oct 2010 17:18:18 +0100 Michael Foord fuzzy...@voidspace.org.uk wrote: Generally I'm +0 on relative imports as a whole. As the OP pointed out, for code that may be *included* in other projects there is no other choice. This is often useful for packages shared between one or

Re: [Python-Dev] question/comment about documentation of relative imports

2010-10-05 Thread Darren Dale
On Tue, Oct 5, 2010 at 12:43 PM, Antoine Pitrou solip...@pitrou.net wrote: On Tue, 05 Oct 2010 17:18:18 +0100 Michael Foord fuzzy...@voidspace.org.uk wrote: Generally I'm +0 on relative imports as a whole. As the OP pointed out, for code that may be *included* in other projects there is

Re: [Python-Dev] question/comment about documentation of relative imports

2010-10-05 Thread Antoine Pitrou
Le mardi 05 octobre 2010 à 13:28 -0400, Darren Dale a écrit : As the OP pointed out, for code that may be *included* in other projects there is no other choice. This is often useful for packages shared between one or two projects that nonetheless don't warrant separate distribution.

Re: [Python-Dev] question/comment about documentation of relative imports

2010-10-05 Thread Éric Araujo
If they were actively discouraged, perhaps performing a relative import would raise a warning, This would be done if this import style was deprecated. It’s different from it being discouraged. or maybe distutils would raise a warning at install time, Distutils does not inspect source files.

Re: [Python-Dev] question/comment about documentation of relative imports

2010-10-05 Thread Darren Dale
On Tue, Oct 5, 2010 at 1:45 PM, Antoine Pitrou solip...@pitrou.net wrote: Le mardi 05 octobre 2010 à 13:28 -0400, Darren Dale a écrit : As the OP pointed out, for code that may be *included* in other projects there is no other choice. This is often useful for packages shared between one

Re: [Python-Dev] question/comment about documentation of relative imports

2010-10-05 Thread Antoine Pitrou
On Tue, 5 Oct 2010 14:17:47 -0400 Darren Dale dsdal...@gmail.com wrote: Thats not the point though. Due to compatibility issues, maybe I don't want to expose the code at the top level. Maybe the foo package is distributed elsewhere as a top-level package, but I need to use an older version

Re: [Python-Dev] question/comment about documentation of relative imports

2010-10-05 Thread Guido van Rossum
On Tue, Oct 5, 2010 at 11:17 AM, Darren Dale dsdal...@gmail.com wrote: The issue is implementing a PEP with nice support for relative imports, and then documenting that it should never be used. Isn't this mostly historical? Until the new relative-import syntax was implemented there were various

Re: [Python-Dev] question/comment about documentation of relative imports

2010-10-05 Thread Terry Reedy
On 10/5/2010 2:21 PM, Guido van Rossum wrote: On Tue, Oct 5, 2010 at 11:17 AM, Darren Daledsdal...@gmail.com wrote: The issue is implementing a PEP with nice support for relative imports, and then documenting that it should never be used. Isn't this mostly historical? Until the new

Re: [Python-Dev] question/comment about documentation of relative imports

2010-10-05 Thread Darren Dale
On Tue, Oct 5, 2010 at 3:37 PM, Terry Reedy tjre...@udel.edu wrote: On 10/5/2010 2:21 PM, Guido van Rossum wrote: On Tue, Oct 5, 2010 at 11:17 AM, Darren Daledsdal...@gmail.com  wrote: The issue is implementing a PEP with nice support for relative imports, and then documenting that it should

Re: [Python-Dev] question/comment about documentation of relative imports

2010-10-05 Thread Nick Coghlan
On Wed, Oct 6, 2010 at 4:21 AM, Guido van Rossum gu...@python.org wrote: On Tue, Oct 5, 2010 at 11:17 AM, Darren Dale dsdal...@gmail.com wrote: The issue is implementing a PEP with nice support for relative imports, and then documenting that it should never be used. Isn't this mostly

Re: [Python-Dev] question/comment about documentation of relative imports

2010-10-05 Thread Oleg Broytman
On Wed, Oct 06, 2010 at 07:09:48AM +1000, Nick Coghlan wrote: The remaining scenarios we have that can lead to duplication of a module happen regardless of the import style you use*. Cheers, Nick. *For the curious - those scenarios relate to ending up with the same module present both as

Re: [Python-Dev] question/comment about documentation of relative imports

2010-10-05 Thread Greg Ewing
Guido van Rossum wrote: Now it is time to withdraw the anti-recommendation. Or at least re-word them all to make it clear that they're talking about the *old* style of relative import in 2.x. -- Greg ___ Python-Dev mailing list Python-Dev@python.org