this post was submitted on 04 Dec 2024
3 points (54.8% liked)

Python

6439 readers
59 users here now

Welcome to the Python community on the programming.dev Lemmy instance!

πŸ“… Events

PastNovember 2023

October 2023

July 2023

August 2023

September 2023

🐍 Python project:
πŸ’“ Python Community:
✨ Python Ecosystem:
🌌 Fediverse
Communities
Projects
Feeds

founded 2 years ago
MODERATORS
 

https://docs.python.org/3/library/pathlib.html

I'm creating this post mainly so that I don't forget the name again.

top 8 comments
sorted by: hot top controversial new old
[–] troyunrau@lemmy.ca 7 points 8 hours ago* (last edited 7 hours ago)

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')    
[–] FizzyOrange@programming.dev 2 points 8 hours ago (1 children)

They still messed up the default encoding though unfortunately.

[–] SwordInStone@lemmy.world 2 points 5 hours ago
[–] Fred@programming.dev 3 points 9 hours ago (1 children)
[–] SwordInStone@lemmy.world 1 points 5 hours ago

sorry, I was looking for it today, which prompted me to create this post

[–] joyjoy@lemm.ee 3 points 9 hours ago

os/os.path functions are named after their C counterparts.

[–] eager_eagle@lemmy.world 1 points 8 hours ago* (last edited 8 hours ago) (1 children)