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

Python

99 readers
3 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 3 comments
sorted by: hot top controversial new old
[–] pnutzh4x0r@lemmy.ndlug.org 4 points 6 days ago (2 children)

Path objects also override the / operator to join paths

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

[–] Midnitte 3 points 5 days ago

A great joy when working with people on a combination of Windows/MacOS/Linux.

Hell, even great when your laptop is windows and desktop (or even raspberry pi) is Linux

[–] Fred@programming.dev 2 points 5 days ago

Scapy is another library where they redefined / to layer packets, such that you can write:

IP(dst="172.23.34.45") / UDP() / DNS(…)

Then Scapy has magic so that on serialisation, the UDP layer knows defaults to dport=53 if the upper layer is DNS, and it can access the lower layer to compute its checksum.

And don't forget that strings have a custom % (as in modulo) operator for formatting:

"Hello %s" %(username)

Of course in modern Python, f-strings will almost always be more convenient