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 question on Stack Overflow.  
My initial response was "well, duh, obviously relative imports are more 
Pythonic here because that's the obvious way to do it (that works)."

But then, of course, PEP 8 disagrees.

For that actual question on Stack Overflow, you would have to carefully define 
the scope of "executing" so that it was fully understood to include 
"subclassing a class defined in a peer module or submodule" -- because that's 
what was breaking.

Just as most people don't think of imports that can be placed in a DAG as 
circular, most people also don't think of subclassing as "executing."

But the Python interpreter sometimes vehemently disagrees in both cases.  I'm 
not surprised at its behavior, but I'm also not surprised that some people who 
haven't thought deeply about the behavior find it surprising.

I'm not fully convinced that this even can be documented in a way that renders 
observed behavior unsurprising in the general case, but I am convinced that 
doing so would require a lot of care.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue25294>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to