On Tue, 06 Oct 2009 10:56:26 -0700, Ryan wrote:
> Good day all!
>
> I've just inherited a large amount of python code. After spending some
> time pour through the code, I've noticed that the original developer
> (who is no longer w/ the company) constantly deletes the imported
> classes at the end of the .py file. Why would one want to do such a
> thing?
Too much lead paint in his milk as a small child? *grin*
Possibly out of a (misplaced?) sense of "keeping the namespace clean", or
a desire to prevent people importing his module and then using the
classes he imports from elsewhere.
Personally, I think it's just a quirk. There's nothing wrong with doing
so, but nor is there anything right with it either. If he's worried about
the presence of an alien class messing up his beautifully designed API,
that's an aesthetic judgment, and can be (partially) managed by using
__all__ (a global list of names). But in general, I would prefer to
manage such namespace issues by saying:
import alienmodule
class MyClass(alienmodule.AlienClass):
do_stuff()
rather than:
from alienmodule import AlienClass
class MyClass(AlienClass):
do_stuff()
del AlienClass
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list