title: Nicest way to find current directory of file in python
body: <p>I'm looking for a replacement of</p>
  
  <pre><code>import os
  package_dir = os.path.dirname(os.path.abspath(__file__))
  file_path = os.path.join(package_dir,'foo.csv')
  </code></pre>
  
  <p>My working path isn’t the path of the file. So when I want to load a file, I need a way to generate the relative path compared to my working directory.</p>
  
  <p>I want to update to pathlib (or whatever else is out there). But what is the nicest way to do the same?</p>
  
  <p>I found <a href="https://stackoverflow.com/a/44188489">https://stackoverflow.com/a/44188489</a>, but I don't think this solution looks better than my current way. </p>
  
  <h3>Remark:</h3>
  
  <p>It's not a duplicate of <a href="https://stackoverflow.com/questions/3718657/how-to-properly-determine-current-script-directory">How to properly determine current script directory?</a>, since I explicitly asked about the nicest way. Most of the solutions in the other post don't look nice, or are already mentioned in the my question. The solution</p>
  
  <pre><code>Path(__file__).with_name("foo.csv")
  </code></pre>
  
  <p>given here is much better than the solutions given in the other question, since it's easy to understand, and a really pythonic way to solve it. If this question was a dublicate, on the other post an equally good answer would exist.</p>