Do imported modules have the same working directory as the file being executed?
<p>Suppose I have a file called <code>myfile.py</code> in <code>/Users/joe/Documents</code>:</p>

<pre><code>import mymodule

mymodule.foobar()
</code></pre>

<p>Now let's say that I need to fetch the current working directory of <code>myfile.py</code> in <code>mymodule</code> (which is in another location). Do they both have the same working directory because I am importing <code>mymodule</code> into <code>myfile</code>, or does <code>mymodule</code> have it's working directory as the directory of where it was installed</p>

<p>Because you are importing the module, they both have the same working directory, meaning that completing operations with <code>os</code> will be successful (or whatever other purpose you are using the current working directory for).</p>

python working-directory