Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

List comprehensions don't exist in their own vacuum though. For generators (the generalization of list comprehensions) and then coroutines, it's a feature that can't be replicated in Python without serious kludges; it does indeed add semantics. It enables you to do more: threads, actor model, state machine, modularize large functions. I think the cost of implementing list comprehensions was more than worth the while for all the benefits that have been reaped from it.


Python could have had generators without having lisp comprehensions, so you don't get to use "generators good" to conclude "list comprehensions good".

List comprehensions were initially syntax for loops over generators. The current version introduces another variable scope.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: