PyWart: Python modules are not so "modular" after all!

Rick Johnson rantingrickjohnson at gmail.com
Mon Nov 11 18:51:08 EST 2013


On Monday, November 11, 2013 1:34:54 AM UTC-6, Steven D'Aprano wrote:
> import sys
> sys.modules["mymodule"] = any_object_you_like()

Thanks for this great advice!

I'm not particularly fond of injecting names and objects in
this manner due to the "surprise factor", especially when
the names are going to be global, but i'm going to do it
anyway since python gives me no other choice!

*evil-grin*

However, there is no reason why "good" cannot prevail over
"evil". By utilizing an intelligent design, logical
hierarchy, and most importantly: quality documentation and
commenting to shine a light on such dark and mystical
practices, i can elevate a kludge into the realms of
elegance.

Stay tuned for a future thread discussion on the topic...



More information about the Python-list mailing list