Re: [Python-Dev] relative import circular problem

2013-04-05 Thread Kristján Valur Jónsson
-Dev [mailto:python-dev- bounces+kristjan=ccpgames@python.org] On Behalf Of Richard Oudkerk Sent: 4. apríl 2013 16:26 To: python-dev@python.org Subject: Re: [Python-Dev] relative import circular problem How about having a form of relative import which only works for submodules

Re: [Python-Dev] relative import circular problem

2013-04-05 Thread Kristján Valur Jónsson
-Original Message- From: PJ Eby [mailto:p...@telecommunity.com] Sent: 4. apríl 2013 20:29 To: Guido van Rossum Cc: Kristján Valur Jónsson; Nick Coghlan; python-dev@python.org Subject: Re: [Python-Dev] relative import circular problem So, this is actually an implementation quirk

Re: [Python-Dev] relative import circular problem

2013-04-05 Thread Kristján Valur Jónsson
; python-dev@python.org Subject: Re: [Python-Dev] relative import circular problem +1 on Brett and PJE just doing this. ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http

Re: [Python-Dev] relative import circular problem

2013-04-04 Thread Kristján Valur Jónsson
-Original Message- From: Eric Snow [mailto:ericsnowcurren...@gmail.com] Sent: 4. apríl 2013 04:57 imported by both of the original modules. At that point, the code is cleaner and more decoupled, and the uneven circular import support ceases to be a problem for that application.

Re: [Python-Dev] relative import circular problem

2013-04-04 Thread Nick Coghlan
On 4 Apr 2013 19:37, Kristján Valur Jónsson krist...@ccpgames.com wrote: -Original Message- From: Eric Snow [mailto:ericsnowcurren...@gmail.com] Sent: 4. apríl 2013 04:57 imported by both of the original modules. At that point, the code is cleaner and more decoupled, and the

Re: [Python-Dev] relative import circular problem

2013-04-04 Thread Guido van Rossum
On Thu, Apr 4, 2013 at 2:36 AM, Kristján Valur Jónsson krist...@ccpgames.com wrote: [...] There can be good and valid reasons to put things that depend on each other in separate modules, for example when trying to separate modules by functionality or simply when splitting a long file into

Re: [Python-Dev] relative import circular problem

2013-04-04 Thread Richard Oudkerk
On 04/04/2013 4:17pm, Guido van Rossum wrote: I don't really see what we could change to avoid breaking code in any particular case -- the burden is up to the library to do it right. I don't see a reason to forbid any of this either. How about having a form of relative import which only works

Re: [Python-Dev] relative import circular problem

2013-04-04 Thread Guido van Rossum
Redirecting to python-ideas. On Thu, Apr 4, 2013 at 9:26 AM, Richard Oudkerk shibt...@gmail.com wrote: On 04/04/2013 4:17pm, Guido van Rossum wrote: I don't really see what we could change to avoid breaking code in any particular case -- the burden is up to the library to do it right. I

Re: [Python-Dev] relative import circular problem

2013-04-04 Thread PJ Eby
On Thu, Apr 4, 2013 at 11:17 AM, Guido van Rossum gu...@python.org wrote: I don't really see what we could change to avoid breaking code in any particular case Actually, the problem has *nothing* to do with circularity per se; it's that import a.b and from a import b behave differently in terms

Re: [Python-Dev] relative import circular problem

2013-04-04 Thread Guido van Rossum
Thanks for the insight. That could indeed be done and I would encourage someone to come up with a fix. FWIW there is another difference between the two forms -- from a import b allows b to be any attribute of a, whereas import a.b requires b to be a submodule of a. I don't want to compromise on

Re: [Python-Dev] relative import circular problem

2013-04-04 Thread PJ Eby
On Thu, Apr 4, 2013 at 4:42 PM, Guido van Rossum gu...@python.org wrote: I do think it would be fine if from a import b returned the attribute 'b' of module 'a' if it exists, and otherwise look for module 'a.b' in sys.modules. Technically, it already does that -- but inside of __import__, not

Re: [Python-Dev] relative import circular problem

2013-04-04 Thread Cameron Simpson
On 03Apr2013 12:12, Greg Ewing greg.ew...@canterbury.ac.nz wrote: | Kristján Valur Jónsson wrote: | However, relative imports can _only_ be performed using the from X import Y syntax | | This seems like a legitimate complaint on its own, [...] | There are a couple of ways that this could be

Re: [Python-Dev] relative import circular problem

2013-04-04 Thread Brett Cannon
On Thu, Apr 4, 2013 at 5:00 PM, PJ Eby p...@telecommunity.com wrote: On Thu, Apr 4, 2013 at 4:42 PM, Guido van Rossum gu...@python.org wrote: I do think it would be fine if from a import b returned the attribute 'b' of module 'a' if it exists, and otherwise look for module 'a.b' in

Re: [Python-Dev] relative import circular problem

2013-04-04 Thread Guido van Rossum
+1 on Brett and PJE just doing this. On Thu, Apr 4, 2013 at 3:38 PM, Brett Cannon br...@python.org wrote: On Thu, Apr 4, 2013 at 5:00 PM, PJ Eby p...@telecommunity.com wrote: On Thu, Apr 4, 2013 at 4:42 PM, Guido van Rossum gu...@python.org wrote: I do think it would be fine if from a

Re: [Python-Dev] relative import circular problem

2013-04-04 Thread Brett Cannon
On Apr 4, 2013 6:47 PM, Guido van Rossum gu...@python.org wrote: +1 on Brett and PJE just doing this. I'll file a bug when I get home. -brett On Thu, Apr 4, 2013 at 3:38 PM, Brett Cannon br...@python.org wrote: On Thu, Apr 4, 2013 at 5:00 PM, PJ Eby p...@telecommunity.com wrote:

Re: [Python-Dev] relative import circular problem

2013-04-04 Thread Brett Cannon
http://bugs.python.org/issue17636 On Thu, Apr 4, 2013 at 8:03 PM, Brett Cannon br...@python.org wrote: On Apr 4, 2013 6:47 PM, Guido van Rossum gu...@python.org wrote: +1 on Brett and PJE just doing this. I'll file a bug when I get home. -brett On Thu, Apr 4, 2013 at 3:38 PM,

Re: [Python-Dev] relative import circular problem

2013-04-03 Thread Eric Snow
On Mon, Apr 1, 2013 at 4:52 PM, Nick Coghlan ncogh...@gmail.com wrote: This is really a quality-of-implementation issue in the import system rather than a core language design problem. It's just that those of us with the knowledge and ability to fix it aren't inclined to do so because circular

Re: [Python-Dev] relative import circular problem

2013-04-02 Thread Kristján Valur Jónsson
2013 22:38 To: Kristján Valur Jónsson Cc: python-dev@python.org Subject: Re: [Python-Dev] relative import circular problem the latter works with partially initialized modules, but not the former, rendering two sibling modules unable to import each other using the relative syntax. Clarification

Re: [Python-Dev] relative import circular problem

2013-04-02 Thread Kristján Valur Jónsson
: Re: [Python-Dev] relative import circular problem with partially initialized modules, but not the former, rendering two sibling modules unable to import each other using the relative syntax. This is really a quality-of-implementation issue in the import system rather than a core language

Re: [Python-Dev] relative import circular problem

2013-04-02 Thread Kristján Valur Jónsson
-Original Message- From: Python-Dev [mailto:python-dev- bounces+kristjan=ccpgames@python.org] On Behalf Of Barry Warsaw Sent: 1. apríl 2013 22:16 To: python-dev@python.org Subject: Re: [Python-Dev] relative import circular problem On Apr 01, 2013, at 08:20 PM, Kristján Valur

Re: [Python-Dev] relative import circular problem

2013-04-02 Thread Antoine Pitrou
Le Tue, 2 Apr 2013 09:28:17 +, Kristján Valur Jónsson krist...@ccpgames.com a écrit : Right, as I explained in my reply to Barry, I was imprecise. But the “from X import Y” is the only way to invoke relative imports, where X can have leading dots. This syntax places the constraint on X

Re: [Python-Dev] relative import circular problem

2013-04-02 Thread Greg Ewing
Kristján Valur Jónsson wrote: However, relative imports can _only_ be performed using the from X import Y syntax This seems like a legitimate complaint on its own, regardless of the circular import issue. The principle of least surprise suggests that relative imports should be possible using

[Python-Dev] relative import circular problem

2013-04-01 Thread Kristján Valur Jónsson
I just ran into the issue described in http://stackoverflow.com/questions/6351805/cyclic-module-dependencies-and-relative-imports-in-python. This is unfortunate, because we have been trying to move towards relative imports in order to aid flexibility in package and library design. The relative

Re: [Python-Dev] relative import circular problem

2013-04-01 Thread Barry Warsaw
On Apr 01, 2013, at 08:20 PM, Kristján Valur Jónsson wrote: The relative import syntax (from foo import bar) is a getattr type of lookup (i.e. import foo, then get attr from it). This is in contrast with absolute import import foo.bar (get the module foo.bar from sys.modules or import it)

Re: [Python-Dev] relative import circular problem

2013-04-01 Thread Brett Cannon
On Mon, Apr 1, 2013 at 4:20 PM, Kristján Valur Jónsson krist...@ccpgames.com wrote: I just ran into the issue described in http://stackoverflow.com/questions/6351805/cyclic-module-dependencies-and-relative-imports-in-python . This is unfortunate, because we have been trying to move towards

Re: [Python-Dev] relative import circular problem

2013-04-01 Thread Nick Coghlan
On Tue, Apr 2, 2013 at 6:20 AM, Kristján Valur Jónsson krist...@ccpgames.com wrote: I just ran into the issue described in http://stackoverflow.com/questions/6351805/cyclic-module-dependencies-and-relative-imports-in-python . This is unfortunate, because we have been trying to move towards