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

Thanks for the clarification. I didn't know that until i started messing with them just now for my post.

Heres a a clearer example(you could deduce this from my previous post): >>> x=((lambda n: i + n) for i in range(10)) >>> y=((lambda i: lambda n: i + n)(i) for i in range(10)) >>> [f for f in x]==[i for i in y] True

this is with generators.

with list comprehensions it becomes: >>> x=[(lambda n: i + n) for i in range(10)] >>> y=[(lambda i: lambda n: i + n)(i) for i in range(10)] >>> [f for f in x]==[i for i in y] False



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

Search: