On Tue, 15 Jun 2010 20:34:47 -0700, Michele Simionato wrote: > On Jun 16, 4:43 am, John Nagle <na...@animats.com> wrote: >> Is it possible to override "__setattr__" of a module? I >> want to capture changes to global variables for debug purposes. [...] > There is a dirty trick which involves fiddling with sys.modules. For > instance: [snip example of installing a class in sys.modules]
I'm not sure that this is a dirty trick. Isn't it officially supported? If I recall correctly, Python used to insist that modules in sys.modules were actual module objects, and that restriction was lifted deliberately to allow clever tricks like this. Or am I thinking of something else? -- Steven -- http://mail.python.org/mailman/listinfo/python-list