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

Even clearer:

    x = [for word in words: for letter in word: letter]
This also has the advantage of being readable left to right without encountering any unbound identifiers like all other constructs in Python.


As someone who spends a significant amount of time in python that is much harder to follow. There is an expectation for order in list comprehensions and what you wrote completely violates it.




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

Search: