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

I would add generator expressions:

    (f(x) for x in list_of_inputs)
Just like a list comprehension, but with (...) rather than [...] and with lazy evaluation.

These are useful when you don't need to evaluate all of the inputs at once but still want to iterate over them at some point later on.



Not to mention how awesome they become when you feed them as a set of values to a function.

    values = (f(x) for x in list)
    g(*values)




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

Search: