Dynamically import a package from a directory
<p>I am making a server that listens on a socket. Whenever a new request comes in, the server spawns a new instance of handle_request. Each instance of handle_request.py <strong>imports the relevant handler</strong> from request_handlers.</p>

<pre><code>server.py
handle_request.py
request_handlers
|_handler_beta
|_handler_1
|_handler_2
</code></pre>

<p><strong>While handlerX is a module, request_handlers is not a package</strong>. The modules are self-contained and reloaded on each request. The modules may be added, modified or dropped while the program is running.</p>

<hr>

<p><strong>Question</strong>: What is the way to import a module from an arbitrary directory?</p>

<hr>

<p>Doing my homework, I saw that most questions deal with <strong>packages</strong>, even one is titled "<em>python: import a module from a folder</em>". Hence I believe this question is distinct. The architecture has been simplified; and yes, I am considering pre-forking with reload on file modification.</p>
