13
submitted 3 weeks ago* (last edited 3 weeks ago) by SwordInStone@lemmy.world to c/python@programming.dev

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

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

you are viewing a single comment's thread
view the rest of the comments
[-] troyunrau@lemmy.ca 14 points 3 weeks ago* (last edited 3 weeks 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')    
[-] kabi@lemm.ee 2 points 3 weeks ago

Disgusting. I love it!

this post was submitted on 04 Dec 2024
13 points (65.9% liked)

Python

6474 readers
4 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