Locking on file locations in a large Python project
<p>When a Python project gets big, certain code segments, such as utility functions, tend to be run from various locations:</p>

<ul>
<li>from a <code>__main__</code></li>
<li>from a django server process</li>
<li>from a test in a test suite</li>
</ul>

<p>In each case the working directory for the python interpreter may be different and assuming the project spans over a sub-directory tree, the following line doesn't always work:</p>

<pre><code>with open('some_file.xml','r') as my_xml:
</code></pre>

<p>It doesn't work because <code>some_file.xml</code> isn't always in your working directory. You need to be specific regarding the file's location, however, the project may be deployed in various environments so simply adding the directory to the <code>open</code> statement isn't a good solution.</p>

<p>What would be an elegant and efficient way to "lock on" the location of the file throughout the project?</p>
