SwordInStone@lemmy.world to Python@programming.dev · edit-27 days agoYSK: there is a library called pathlib with different methods for accessing files which you might like since they do not require a context manager message-squaremessage-square10fedilinkarrow-up127file-text
arrow-up127message-squareYSK: there is a library called pathlib with different methods for accessing files which you might like since they do not require a context manager SwordInStone@lemmy.world to Python@programming.dev · edit-27 days agomessage-square10fedilinkfile-text
https://docs.python.org/3/library/pathlib.html I’m creating this post mainly so that I don’t forget the name again.
minus-squareTroy@lemmy.calinkfedilinkarrow-up13·edit-28 days agoIt’s also a really fun example of operator overloading. __div__ is overloaded to allow this syntax. >>> p = PurePath('/etc') >>> p PurePosixPath('/etc') >>> p / 'init.d' / 'apache2' PurePosixPath('/etc/init.d/apache2')
It’s also a really fun example of operator overloading.
__div__
is overloaded to allow this syntax.>>> p = PurePath('/etc') >>> p PurePosixPath('/etc') >>> p / 'init.d' / 'apache2' PurePosixPath('/etc/init.d/apache2')
Disgusting. I love it!