Hacker News new | past | comments | ask | show | jobs | submit login

Perhaps more comparable to the comprehensions shown in this post would be generator comprehensions:

    list(p.first_name + " " + p.last_name for p in people)
    dict((p.first_name + " " + p.last_name, p) for p in people)
    set(j.organization for p in people for j in p.jobs)
    print(", ".join(p.first_name + " " + p.last_name for p in people))
(Of course, Python has sugar for the first three.)



What's the sugar for the third?


    set(j.organization for p in people for j in p.jobs)
    {j.organization for p in people for j in p.jobs}
The latter is available from Python 2.7+.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

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

Search: