SwordInStone@lemmy.world to Python@programming.dev · edit-26 hours agoYSK: there is a library called pathlib with less stupid methods for accessing filesmessage-squaremessage-square8fedilinkarrow-up120arrow-down114file-text
arrow-up16arrow-down1message-squareYSK: there is a library called pathlib with less stupid methods for accessing filesSwordInStone@lemmy.world to Python@programming.dev · edit-26 hours agomessage-square8fedilinkfile-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-squareTroylinkfedilinkarrow-up8·edit-29 hours 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')