On 26/07/17 19:40, C W wrote: > My understanding of each is: > 1) function(variable) is manipulating a vector, I can do bList = > sorted(aList) > 2) object.method() is permanently changing it, I don't even need to assign > it in #1. > > Why is there both? They do the same thing.
As you have just shown they do very different things. One sorts the list in place the other returns a sorted copy of the list. Sometimes you want one, sometimes the other. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor