using del() to 'unimport'
Donnal Walter
donnal at donnal.net
Sun Nov 24 07:25:28 EST 2002
When the the following module is imported, I want only 'MyClass' (NOT
'Useful' and 'Mixin1') to be publicly accessible.
======= mymodule.py ==================
from utilities import Useful, Mixin1
class MyClass(Useful, Mixin1): pass
======================================
So my question is this: Is it an acceptable Python idiom to use del()
at the end of a module to remove previously imported names from the
global namespace as shown below? Is there a better alternative?
======= mymodule.py ==================
from utilities import Useful, Mixin1
class MyClass(Useful, Mixin1): pass
del(Useful)
del(Mixin1)
======================================
More information about the Python-list
mailing list