c/python · by SwordInStone@lemmy.world · 1yYSK: there is a library called pathlib with different methods for accessing files which you might like since they do not require a context manager https://docs.python.org/3/library/pathlib.html I'm creating this post mainly so that I don't forget the name again. 13 points · 9 comments · view on lemmy.world
9 Comments
troyunrau@lemmy.ca · 15 pts · 1y
It's also a really fun example of operator overloading.
__div__is overloaded to allow this syntax.kabi@lemm.ee · 3 pts · 1y
Fred@programming.dev · 5 pts · 1y
There was a discussion of pathlib a few days ago: https://programming.dev/post/21864360
SwordInStone@lemmy.world · 2 pts · 1y
sorry, I was looking for it today, which prompted me to create this post
dallen@programming.dev · 4 pts · 1y
I subconsciously replace
os.pathwithpathlibwhenever touching any module for a refactor.joyjoy@lemm.ee · 3 pts · 1y
os/os.pathfunctions are named after their C counterparts.eager_eagle@lemmy.world · 2 pts · 1y
you can also enable this rule set to remind you https://docs.astral.sh/ruff/rules/#flake8-use-pathlib-pth
SwordInStone@lemmy.world · 1 pts · 1y
hell ye
FizzyOrange@programming.dev · 2 pts · 1y
They still messed up the default encoding though unfortunately.
SwordInStone@lemmy.world · 2 pts · 1y
😢