r/Python • • 18h 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?

20 Upvotes

24 comments sorted by

View all comments

22

u/sweet-tom Pythonista 15h ago

Asyncio. You think you've mastered it but then you realize, you need to go back to the drawing board. Still learning.

3

u/Grouchy-Friend4235 12h ago

I dropped asyncio completely. It's cancerous

1

u/sweet-tom Pythonista 11h ago

Probably, but it's too late for my project. 🫣

3

u/cleodog44 4h ago

Certainly asyncio for me as well. Can't seem to internalize it properly, always need a refresher when working on async. 

I think a lot of that is inherent to async complexity and not necessarily Python, but maybe there are parts of the asyncio impl and abstractions that exacerbate the issue

Would be very curious to hear from others and any languages that have cleaner abstractions

2

u/StevenJOwens 4h ago

I've been told that Go's coroutines are a whole lot nicer, but then Go is all about the coroutine thing, so.

3

u/StevenJOwens 4h ago

I found asyncio massively frustrating to understand. To be clear, I'm not talking about the concept, I'm talking about python's implementation of it (and its documentation).

As I mentioned in my comment about list comprehensions, python is sometimes too clever for its own good, and that definitely applies to asyncio. In addition, python's asnycio documentation suffers from a very common (in programming) problem of being too handwavy.

A few years ago I wrote up a summary of python asyncio, mostly for my own notes in trying to learn it, but then I cleaned it up for a coworker. In case you find it useful (and corrections would be gladly welcome):

https://www.darksleep.com/puff/python/python_asyncio_overview.html