Brain Dead Singleton
peter at engcorp.com
Mon Jun 7 01:06:58 CEST 2004
Robin Becker wrote:
> Peter Hansen wrote:
>> Colin's suggesting is just fine for most sane situations.
> well I actually have a use case for deleting modules from sys.modules.
> An easy fix involved restoring sys.modules to a pristine state
> before each document was generated.
I'd argue perhaps that "easy fix" should have read "hack", and
that this doesn't fit my condition of "most sane situations".
Would you say that this "fix" was really an elegant solution,
or just a quick hack? I don't think deleting things from
sys.modules has defined, guaranteed behaviour, so I'm uncertain
whether anyone should rely on it working. I still think
Colin's approach is a generally okay one.
More information about the Python-list