Set working directory in Python / Spyder so that it's reproducible
<p>Coming from R, using <code>setwd</code> to change the directory is a big no-no against reproducibility because others do not have the same directory structure as mine. Hence, it's recommended to use relative path from the location of the script.</p>

<p>IDEs slightly complicate this because they set their own working directory. In Rstudio, I can easily get around this problem with Rstudio's projects, setting the project's directory to be my script folder.</p>

<p>With Python and Spyder, there doesn't seem to be any solution. Spyder does not have a feature like Rstudio's project. <a href="https://stackoverflow.com/questions/1432924/python-change-the-scripts-working-directory-to-the-scripts-own-directory">Setting the directory to the script's location</a> does not work while doing interactive analysis (since <code>__file__</code> is not available).</p>

<p>What to do so that the working directory in Python / Spyder is reproducible?</p>