1

The thing I love about python is it's elegance; and I thing that is partially due to its syntactic sugar. Between list comprehensions, destructuring, enumerators, generators with yield, and a bunch more, what is your favorite

top 7 comments
sorted by: hot top controversial new old
[-] Walnut356@programming.dev 2 points 8 months ago

Generators probably. It's the one thing i genuinely miss about python when i work in rust.

[-] sebsch@discuss.tchncs.de 1 points 8 months ago

You're right. Having just yield sth in a function instead of defining the data structure is such a game changer.

[-] lavafroth@programming.dev 0 points 8 months ago

impl Iterator for YourType ?

[-] tatterdemalion@programming.dev 2 points 8 months ago

That's not quite the same as a generator. Iterators require explicit returns to yield control, and this involves dropping the entire stack frame.

True generators allow one to yield, which pauses the function and allows it to be resumed. The most similar thing to this in Rust is an async block/fn, but there is ongoing effort to generalize this so you could create an iterator from a generator.

[-] lavafroth@programming.dev 1 points 8 months ago
[-] Cwilliams@beehaw.org 1 points 7 months ago

Yeah, I'm just learning about decorators in classes, and they're super cool!

[-] KaczuH@lemmy.ml 1 points 7 months ago

Decorators are one of most useful features I'm using most frequently.

this post was submitted on 16 Oct 2023
1 points (100.0% liked)

Python

5891 readers
40 users here now

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

📅 Events

October 2023

November 2023

PastJuly 2023

August 2023

September 2023

🐍 Python project:
💓 Python Community:
✨ Python Ecosystem:
🌌 Fediverse
Communities
Projects
Feeds

founded 1 year ago
MODERATORS