[Python-Dev] relative import circular problem
solipsis at pitrou.net
Tue Apr 2 13:46:06 CEST 2013
Le Tue, 2 Apr 2013 09:28:17 +0000,
Kristján Valur Jónsson <kristjan at 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
> that Y is actually an attribute of X at this time, where “import X.Y”
> does not. So, even without the leading dots issue, they are not
> equivalent. You run into the same circular dependency problem
> without using relative imports if trying to use the “from X import Y”
> where X is an absolute name.
I agree with Kristjan, it is rather annoying.
And it also makes explicit relative imports harder to sell to people
used to the implicit relative import style, since the latter works well
in such circumstances.
More information about the Python-Dev