28 Nov
2016
28 Nov
'16
11 p.m.
On 28.11.2016 23:52, Chris Angelico wrote:
+1, because this also provides a coherent way to reword the try/except import idiom:
# Current idiom # somefile.py try: import foo except ImportError: import subst_foo as foo
# New idiom: # foo.missing.py import subst_foo as foo import sys; sys.modules["foo"] = foo #somefile.py import foo
Hmm. I would rather take this example as an argument against the proposed behavior. It invites too many clever hacks. I thought that the idea was that .missing.py does *not* act as a replacement module, but, more or less, just as a message generator.