pypsa-earth icon indicating copy to clipboard operation
pypsa-earth copied to clipboard

Move from os to pathlib

Open pz-max opened this issue 2 years ago • 2 comments

From Discord: "os.path vs pathlib": https://builtin.com/software-engineering-perspectives/python-pathlib The os module represents paths as strings with which you cannot do much. The pathlib module represents paths as special objects with useful methods and attributes.

Max: Let's use Pathlib by default. Tracking this here as a feature request so someone can work on the transition in future. I think it is a nice exercise for new contributors to get familiar with the code & the git workflow

pz-max avatar Oct 29 '22 10:10 pz-max

Hi all, I picked up this issue as a good first issue to get familiar with the code :)

A few important notes:

  1. pathlib.Path.walk is available starting from the Python version 3.12. Hence for the moment I am keeping the equivalent command from the os package (i.e. os.walk)
  2. pathlib does not provide an equivalent command to os.chdir. Hence I kept the latter

finozzifa avatar Apr 25 '24 08:04 finozzifa

Hey @finozzifa! Perfect, thanks a lot for taking this :)

@pz-max if you have any insights on that, feel free to share :D

ekatef avatar Apr 25 '24 09:04 ekatef