- Relative imports for intra-package imports are highly
discouraged.
Always use the absolute package path for all imports.
(However, once PEP 328 [7] is fully implemented, its style of
explicit relative imports will be recommended.)
I think that Python 2.5 will issue deprication warnings, so it would be
a good idea to use absolute paths or do the from __future__ import
absolute_import thing. I know this could be a problem with Python 2.3,
but worth considering.
Randall
Good catch. Can you open a ticket on this?
Thanks,
Kevin
> While browsing through the source code, I've seen lots of relative
> imports, which is discouraged in the PEP 8 style guide.
>
> - Relative imports for intra-package imports are highly
> discouraged.
> Always use the absolute package path for all imports.
> (However, once PEP 328 [7] is fully implemented, its style of
> explicit relative imports will be recommended.)
>
> I think that Python 2.5 will issue deprication warnings
I find that a bit unlikely.
> so it would be a good idea to use absolute paths or do the from __future__
> import absolute_import thing.
What absolute_import thing ?
$ python2.4
Python 2.4.1 (#1, Aug 11 2005, 18:03:42)
>>> from __future__ import absolute_import
File "<stdin>", line 1
SyntaxError: future feature absolute_import is not defined
$ python2.5
Python 2.5a0 (trunk:42225M, Feb 2 2006, 21:01:41)
>>> from __future__ import absolute_import
SyntaxError: future feature absolute_import is not defined (<stdin>,
line 1)
> I know this could be a problem with Python 2.3,
> but worth considering.
Optimizing for Python 3.0 is a bit of a premature optimization...
</F>
Wow. That PEP appears to be very wrong.
Nevertheless, getting rid of relative imports in the code is a good plan.
Kevin