PEP 238 - import .relative
PEP 238 which has been accepted and may have an impact on any Python packages you've made so far, depending on your import style. This PEP will change the way imports work in a package. By default, all imports will be concidered absolute. Previously, if you had a Python package named 'Foo' with modules 'Bar' and 'Fig', you could import 'Fig' from the 'Bar' module by typing 'import Fig'. Once this new feature is implemented in Python 2.5, it will look for 'Fig' in sys.path first. They also plan to implement relative imports as well. With this you will be able to import the 'Fig' module from 'Bar' by typing 'import .Fig' for more a better example, see Guido's Decision or read the entire PEP.
from os import (path,
Which allows for easyier multi-line imports. Check out the PEP for additional information.
Note that you can use the new features in Python 2.4 using:
'from __future__ import absolute_import'
In Python 2.5, any package that results in a relative import from a module from within a package will result in a DeprecationWarning. Python 2.6 will include the fully implemented and on by default PEP 238.
The import statement has two problems:
- Long import statements can be difficult to write, requiring
various contortions to fit Pythonic style guidelines.
- Imports can be ambiguous in the face of packages; within a package,
it's not clear whether import foo refers to a module within the
package or some module outside the package. (More precisely, a local
module or package can shadow another hanging directly off
For the first problem, it is proposed that parentheses be permitted to
enclose multiple names, thus allowing Python's standard mechanisms for
multi-line values to apply. For the second problem, it is proposed that
all import statements be absolute by default (searching sys.path
only) with special syntax (leading dots) for accessing package-relative
Let me know if this post was useful or not, so I'll know wether or not to post something like this again. I hope everyone finds this post to be useful.