On Mon, Nov 9, 2015 at 11:00 AM, Ben Finney <ben+pyt...@benfinney.id.au> wrote: > BartC <b...@freeuk.com> writes: > >> Is this typical Python code? Creating global objects in other modules >> (or writing all over essential data structures in a library module). > > Not “creating global objects”, but changing the referent of a name in > some other module. Yes, that's quite a common technique. Does that > surprise you?
Changing the referent of an existing name, definitely. Creating new names, not so much. You don't often reach into another module and create a new attribute. Testing/mocking is a completely separate consideration (eg you can inject a shadow for a built-in name); if some Python implementation has a fast path that gets defeated by "module.int = MagicInt", and it causes the tests to run slower, so be it. Other than that, I can't think of many cases (actually, can't think of any, off hand) where you inject names into other modules. ChrisA -- https://mail.python.org/mailman/listinfo/python-list