Many questions have been asked regarding how to import Python modules, specifically on whether to use absolute or explicit relative import (here for example). The import style, as suggested by the Python Software Foundation, can be found here. In short, it recommends absolute import.
I'm writing this question because I assume the guys who develop matplotlib know what they are doing.
Given this assumption and assuming I understand the major/obvious differences between these two kinds of import, I would be interested in understanding the tiny differences between them that influenced the matplotlib's developers to write something like this:
import matplotlib
import matplotlib.cbook as cbook
from matplotlib.cbook import mplDeprecation
from matplotlib import docstring, rcParams
from .transforms import (Bbox, IdentityTransform, TransformedBbox,
TransformedPath, Transform)
from .path import Path
This is the beginning of artist.py
, contained inside the matplotlib
module (i.e. matplotlib.artist
). I'm looking at matplotlib-1.5.1.
I would like to focus the attention on modules matplotlib.cbook
, matplotlib.transforms
, and matplotlib.path
. All three of them are pure Python modules (i.e. module_name.py
files).
Why from matplotlib.cbook import mplDeprecation
has been chosen rather than from .cbook import mplDeprecation
and why from .path import Path
was preferred to from matplotlib.path import Path
?
Perhaps there is no particular reason and these choices just reflect different styles of different developers; perhaps there is something I'm missing.