On Sun, Nov 7, 2010 at 6:31 PM, Hugo Arts <hugo.yo...@gmail.com> wrote:

> <snip>
> here's a list comprehension
> >>> a = [x*2 for x in range(10)]
> >>> a
> [0, 2, 4, 6, 8, 10, 12, 14, 16, 18]
>
> here's the equivalent generator expression:
> >>> a = (x*2 for x in range(10))

 <snip>


Since you're talking about generators and efficiency, it's probably a good
idea to point out that range is only a generator in python 3.x. In python
2.x it creates a list.

Wayne
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to