โฒ 2 โผ What is your favorite Python syntactic sugar? (beehaw.org) submitted 2 years ago by Cwilliams@beehaw.org to c/python@programming.dev 7 comments fedilink hide all child comments 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
[โ] lavafroth@programming.dev 0 points 2 years ago (1 child) impl Iterator for YourType ? permalink fedilink source parent hideshow 2 child comments replies: [โ] tatterdemalion@programming.dev 2 points 2 years ago (1 child) 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. permalink fedilink source parent hideshow 2 child comments replies: [โ] lavafroth@programming.dev 1 point 2 years ago cool! permalink fedilink source parent
[โ] tatterdemalion@programming.dev 2 points 2 years ago (1 child) 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. permalink fedilink source parent hideshow 2 child comments replies: [โ] lavafroth@programming.dev 1 point 2 years ago cool! permalink fedilink source parent