pythonimporttwistedtwistd

What does `import _preamble` do in Python?


I notice the following at the top of Twisted's twistd.py script:

import os, sys

try:
    import _preamble
except ImportError:
    sys.exc_clear()

sys.path.insert(0, os.path.abspath(os.getcwd()))

What does import _preamble do? I can't seem to find any references to it on the google-mage.


Solution

  • _preamble is a module like any other. In twisted's case, this is simply the module that sets up sys.path so that you can run twisted in development setups.