del an imported Class at EOF... why?
alex23
wuwei23 at gmail.com
Tue Oct 6 20:41:44 EDT 2009
Steven D'Aprano <ste... at REMOVE.THIS.cybersource.com.au> wrote:
> import alienmodule
>
> class MyClass(alienmodule.AlienClass):
> do_stuff()
>
> rather than:
>
> from alienmodule import AlienClass
>
> class MyClass(AlienClass):
> do_stuff()
>
> del AlienClass
The original developer may also have been unaware of the ability to
limit a * import through the use of __all__.
from alienmodule import AlienClass
__all__ = ['MyClass']
class MyClass(AlienClass):
do_stuff()
Of course, this is really only useful if you're doing "from module
import *" which is generally discouraged inside actual code.
More information about the Python-list
mailing list