Re: [Tutor] list semantics

2015-04-11 Thread Joel Goldstick
On Sat, Apr 11, 2015 at 3:21 PM, Steven D'Aprano 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 a genera

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. > > py> range(1, 10) # This is not. > range(1, 10) Oop

Re: [Tutor] list semantics

2015-04-11 Thread Mark Lawrence
On 11/04/2015 20:02, Steven D'Aprano wrote: 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)

Re: [Tutor] list semantics

2015-04-11 Thread Steven D'Aprano
On Sat, Apr 11, 2015 at 02:15:49PM -0400, Joel Goldstick wrote: > On Sat, Apr 11, 2015 at 1:41 PM, 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

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 conver

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 Joel Goldstick
On Sat, Apr 11, 2015 at 1:41 PM, 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)) > Assuming you are using python 3.x ran

[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!" __