this post was submitted on 18 Nov 2024
6 points (100.0% liked)

Python

6375 readers
30 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 1 year ago
MODERATORS
top 6 comments
sorted by: hot top controversial new old
[–] pnutzh4x0r@lemmy.ndlug.org 4 points 4 hours ago (1 children)

Path objects also override the / operator to join paths

This is both cool and gross... gives me C++ vibes (operator overloading abuse).

[–] Diplomjodler3@lemmy.world 2 points 3 hours ago (1 children)

They could have chosen a better operator. But the functionality is fantastic. Makes working with paths so much easier. And you can even use slashes on windows paths.

[–] leds@feddit.dk 1 points 14 minutes ago

It makes the code so much more clean and readable since you're dropping multiple levels of brackets , for example

os.path.join( a, b, os.path.dirname(c))

Becomes

a / b / c.parent

I really like it

[–] eager_eagle@lemmy.world 1 points 3 hours ago (1 children)

Nice, mypath.open() is a more semantic alternative to open(my path)

[–] joyjoy@lemm.ee 1 points 3 hours ago (1 children)

Don't forget about the helper functions mypath.read_text() and mypath.write_text(content)

[–] eager_eagle@lemmy.world 1 points 3 hours ago

that's already in the cheatsheet