this post was submitted on 04 Dec 2024
14 points (66.7% liked)

Python

6598 readers
40 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.

you are viewing a single comment's thread
view the rest of the comments
[โ€“] troyunrau@lemmy.ca 15 points 2 months ago* (last edited 2 months ago) (1 children)

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 3 points 2 months ago

Disgusting. I love it!