Hacker News new | ask | show | jobs
by o11c 239 days ago
That's talking about internal imports (and static - as much as python supports - ones at that), not external ones.

If A is my application, B is buggy, and C is some other library, consider:

  # A.py
  monkeypatch_B()
  import C

  # C.py
  B = __import__('B')

  # B.py
  bugs()
1 comments

It should in theory be possible to mount the new virtual package over the lower module - but I don't think works currently (I'll have to test this). Doing this would make modifications available globally like you describe.