[Tutor] list semantics
Joel Goldstick
joel.goldstick at gmail.com
Sat Apr 11 20:15:49 CEST 2015
On Sat, Apr 11, 2015 at 1:41 PM, Jim Mooney <cybervigilante at gmail.com> wrote:
> Why does the first range convert to a list, but not the second?
>
>>>> p = list(range(1,20)), (range(40,59))
>>>> p
> ([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],
> range(40, 59))
>
Assuming you are using python 3.x range is a generator, so it only
produces values if you iterate over it
> --
> Jim
>
> "Stop, Harold! That bagel has radishes!"
> "Thank God, Mary - you've saved me again!"
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
--
Joel Goldstick
http://joelgoldstick.com
More information about the Tutor
mailing list