Python simulate an imported module

Reply to comment

As used in nltk: # Override missing methods on environments where it cannot be used like GAE. import subprocess if not hasattr(subprocess, 'PIPE'):     def _fake_PIPE(*args, **kwargs):         raise NotImplementedError('subprocess.PIPE is not supported.')     subprocess.PIPE = _fake_PIPE if not hasattr(subprocess, 'Popen'):     def _fake_Popen(*args, **kwargs):         raise NotImplementedError('subprocess.Popen is not supported.')     subprocess.Popen = _fake_Popen https://github.com/nltk/nltk/blob/develop/nltk/__init__.py