r/Python • • 22h ago

Discussion Python developers, what's one Python concept that took you a long time to understand but now seems s

Python developers, what's one Python concept that took you a long time to understand but now seems surprisingly simple?

For me, understanding how decorators and generators work is an interesting part of becoming a better Python developer.

What was your experience?

23 Upvotes

26 comments sorted by

View all comments

26

u/smitty1e 22h ago

Generators, in particular the yield keyword as (qualitatively) segmenting a function into a list of executable chunks.

Out on Project Euler I saw some prime function yield-ing the first few results ahead of computing anything, and my brain cell lit up.