On Sat, Feb 19, 2011 at 11:30 AM, Raymond Hettinger raymond.hettinger@gmail.com wrote:
On Feb 18, 2011, at 12:36 PM, Brett Cannon wrote:
It says they are "highly discouraged" because "absolute imports are more portable and usually more readable", but now that people have had a chance to use explicit relative imports, do people still believe this? I mean if we truly believed this then why did we add the syntax? I know I have used it and love it, let alone that I don't buy the portability argument.
I still find relative imports to be a bit jarring and don't like the implied tight coupling of modules. The nest of relative imports in unittest is a good example of something that causes a mental hiccup when I read it and it seems like an anti-pattern.
The particular pattern employed by unittest would be a pseudo-module (i.e. a package that tries to present itself as really just a module) rather than explicit relative imports in general, though.
I'm personally fine with PEP 8 continuing to advocate absolute imports. Explicit relative imports make certain kinds of code easier to write, but they shouldn't be the default choice for a new project.
Cheers, Nick.
-- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia