del an imported Class at EOF... why?
Ryan
heniser at yahoo.com
Wed Oct 7 05:31:00 EDT 2009
Thanks everyone for your insight. I'm going to have to agree with the
paranoid desire to prevent people importing his module and then using
the
classes he imports from elsewhere (I'm not ruling out the lead paint
theory until I can gather more evidence). It does beg the question for
me. Consider the example from his code below
from PyQt4 import QtGui
class LauncherWidget( QtGui.QWidget ):
# A Specialization of QWidget
del QtGui
Next time python comes across
from PyQt4 import QtGui
it would have to re-import the class, which seems a waste of cycles
that could accumulate. In this situation, the use of __all__ is
better. Plus, by using __all__ instead of del you do not have to worry
about forgetting to del a class.
Ryan
More information about the Python-list
mailing list