Re: [Tutor] Puzzled by print lst.sort()

2006-10-01 Thread Liam Clarke
Dick Moores wrote: > At 01:37 PM 9/30/2006, Shantanoo Mahajan wrote: > >> Maybe following is helpful: >> >> > a=[3,2,1] > b=a[:] > b.sort() > c=sorted(a) > print a,b,c > [3, 2, 1] [1, 2, 3] [1, 2, 3] > > >> Shantanoo >> > > Sorry to be dense,

Re: [Tutor] Puzzled by print lst.sort()

2006-10-01 Thread Dick Moores
At 01:37 PM 9/30/2006, Shantanoo Mahajan wrote: >Maybe following is helpful: > > >>> a=[3,2,1] > >>> b=a[:] > >>> b.sort() > >>> c=sorted(a) > >>> print a,b,c > >>> [3, 2, 1] [1, 2, 3] [1, 2, 3] > >>> > >Shantanoo Sorry to be dense, but I don't see what showing what happens to a copy of list a ad

Re: [Tutor] Puzzled by print lst.sort()

2006-09-30 Thread Shantanoo Mahajan
+++ Dick Moores [30-09-06 10:47 -0700]: | At 05:07 AM 9/30/2006, Liam Clarke wrote: | >Dick Moores wrote: | > > At 03:22 AM 9/30/2006, Liam Clarke wrote: | > >> Dick Moores wrote: | | > >> A Python list sort is destructive, as you can see - it has modified | > >> lst. So, to emphasise that it is d

Re: [Tutor] Puzzled by print lst.sort()

2006-09-30 Thread Dick Moores
At 05:07 AM 9/30/2006, Liam Clarke wrote: >Dick Moores wrote: > > At 03:22 AM 9/30/2006, Liam Clarke wrote: > >> Dick Moores wrote: > >> A Python list sort is destructive, as you can see - it has modified > >> lst. So, to emphasise that it is destructive, it returns None. You'll > >> find this in

Re: [Tutor] Puzzled by print lst.sort()

2006-09-30 Thread Liam Clarke
Dick Moores wrote: > At 03:22 AM 9/30/2006, Liam Clarke wrote: >> Dick Moores wrote: >>> >>> >>> lst = [5,3,7,6,2] >>> >>> lst.sort() >>> >>> lst >>> [2, 3, 5, 6, 7] >>> >>> lst = [5,3,7,6,2] >>> >>> print lst.sort() >>> None >>> >>> lst >>> [2, 3, 5, 6, 7] >>> >>> I'm wondering why "print ls

Re: [Tutor] Puzzled by print lst.sort()

2006-09-30 Thread Liam Clarke
Dick Moores wrote: > At 03:22 AM 9/30/2006, Liam Clarke wrote: >> Dick Moores wrote: >>> >>> >>> lst = [5,3,7,6,2] >>> >>> lst.sort() >>> >>> lst >>> [2, 3, 5, 6, 7] >>> >>> lst = [5,3,7,6,2] >>> >>> print lst.sort() >>> None >>> >>> lst >>> [2, 3, 5, 6, 7] >>> >>> I'm wondering why "print ls

Re: [Tutor] Puzzled by print lst.sort()

2006-09-30 Thread Dick Moores
At 03:22 AM 9/30/2006, Liam Clarke wrote: Dick Moores wrote:  >>> lst = [5,3,7,6,2]  >>> lst.sort()  >>> lst [2, 3, 5, 6, 7]  >>> lst = [5,3,7,6,2]  >>> print lst.sort() None  >>> lst [2, 3, 5, 6, 7] I'm wondering why "print lst.sort()" doesn't print the newly sorted list, but instead prints

Re: [Tutor] Puzzled by print lst.sort()

2006-09-30 Thread Liam Clarke
Dick Moores wrote: >>> lst = [5,3,7,6,2] >>> lst.sort() >>> lst [2, 3, 5, 6, 7] >>> lst = [5,3,7,6,2] >>> print lst.sort() None >>> lst [2, 3, 5, 6, 7] I'm wondering why "print lst.sort()" doesn't print the newly sorted list, but instead prints "None". In fact, the sorting has taken

[Tutor] Puzzled by print lst.sort()

2006-09-30 Thread Dick Moores
>>> lst = [5,3,7,6,2] >>> lst.sort() >>> lst [2, 3, 5, 6, 7] >>> lst = [5,3,7,6,2] >>> print lst.sort() None >>> lst [2, 3, 5, 6, 7] I'm wondering why "print lst.sort()" doesn't print the newly sorted list, but instead prints "None". In fact, the sorting has taken place because of "print l