From: John H. <jd...@gm...> - 2007-12-13 18:18:26
|
Do we need namespace packages in toolkits? I recently added gtktools and exceltools to toolkits, and got a very hard to debug error: In [1]: import matplotlib In [2]: matplotlib.__file__ Out[2]: '/home/titan/johnh/dev/lib/python2.4/site-packages/matplotlib/__init__.pyc' In [3]: matplotlib.rcParams['axes.axisbelow'] Out[3]: False In [4]: import matplotlib.toolkits.gtktools In [5]: matplotlib.__file__ Out[5]: '/opt/app/g++lib6/python-2.4/lib/python2.4/site-packages/matplotlib/__init__.pyc' In [6]: matplotlib.rcParams['axes.axisbelow'] ------------------------------------------------------------ Traceback (most recent call last): File "<ipython console>", line 1, in ? KeyError: 'axes.axisbelow' Notice that the matplotlib module which was previously imported got changed by the import of the toolkit which declared itself a namespace package. Now this may be the result of mpl not using namespace packages correctly (eg matplotlib/__init__.py should be empty save for the namespace package or something like that) but I gotta tell ya, this looks just plain wrong. Had I not known that namespace packages were funky like this, it could have taken me a long time to trace this bug. I am going to comment out the toolkits namespace package code until I hear persuasive arguments to the contrary, and until we fix the rest of mpl to work properly with them. JDH |