Re: [Tutor] list semantics

2015-04-11 Thread Joel Goldstick
On Sat, Apr 11, 2015 at 1:41 PM, Jim Mooney cybervigila...@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

Re: [Tutor] list semantics

2015-04-11 Thread Joel Goldstick
On Sat, Apr 11, 2015 at 3:21 PM, Steven D'Aprano st...@pearwood.info wrote: On Sun, Apr 12, 2015 at 05:09:43AM +1000, Steven D'Aprano wrote: Almost correct, but not quite. range, like xrange in Python 2, is not a generator, but a custom-made lazy sequence object. py gen() # This actually is

Re: [Tutor] list semantics

2015-04-11 Thread Timo
Op 11-04-15 om 19:41 schreef Jim Mooney: 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)) I'm not sure I understand correctly. This is what the top

Re: [Tutor] list semantics

2015-04-11 Thread Steven D'Aprano
On Sat, Apr 11, 2015 at 10:41:28AM -0700, Jim Mooney 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)) Why would the second convert to a

Re: [Tutor] list semantics

2015-04-11 Thread Steven D'Aprano
On Sun, Apr 12, 2015 at 05:09:43AM +1000, Steven D'Aprano wrote: Almost correct, but not quite. range, like xrange in Python 2, is not a generator, but a custom-made lazy sequence object. py gen() # This actually is a generator. generator object gen at 0xb7bd7914 py range(1, 10) # This

[Tutor] list semantics

2015-04-11 Thread Jim Mooney
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)) -- Jim Stop, Harold! That bagel has radishes! Thank God, Mary - you've saved me again!