On Wed, Sep 14, 2016 at 9:35 AM, Greg Ewing email@example.com wrote:
Chris Angelico wrote:
It's a little bit magical, in that it looks up the original class using globals();
The way you've written it, monkeypatch() will only work if you call it from the module it's defined in.
Yes. You could tweak that by looking at cls.__module__ and grab it from sys.modules, but I kept the example simple. However, I would NOT use the standard name lookup mechanism.