Re: [Tutor] append vs list addition

2014-05-06 Thread Denis Heidtmann
On Tue, May 6, 2014 at 1:21 PM, Dave Angel wrote: > You're right to be confused; my fingers were confused typing my > last sentence. It should have ended: >... you should use + . > > Likewise the previous thought should have said: > > But in any similar > example, if list2 is t

Re: [Tutor] append vs list addition

2014-05-06 Thread Dave Angel
Denis Heidtmann Wrote in message: > On Sun, May 4, 2014 at 6:44 PM, Dave Angel wrote: >> C Smith Wrote in message: >>> Sorry. >>> >>> I meant for example: >>> list1 = [1,2,3] >>> list2 = [3,4,5] >>> >>> newList = list1 + list2 >>> >>> versus >>> >>> for x in list2: >>> list1.append(x) >>> >>

Re: [Tutor] append vs list addition

2014-05-06 Thread Denis Heidtmann
On Sun, May 4, 2014 at 6:44 PM, Dave Angel wrote: > C Smith Wrote in message: >> Sorry. >> >> I meant for example: >> list1 = [1,2,3] >> list2 = [3,4,5] >> >> newList = list1 + list2 >> >> versus >> >> for x in list2: >> list1.append(x) >> >> Which is the preferred way to add elements from on

Re: [Tutor] append vs list addition

2014-05-06 Thread Dave Angel
C Smith Wrote in message: > Sorry. > > I meant for example: > list1 = [1,2,3] > list2 = [3,4,5] > > newList = list1 + list2 > > versus > > for x in list2: > list1.append(x) > > Which is the preferred way to add elements from one list to another? Thank you for switching to text mail. The

Re: [Tutor] append vs list addition

2014-05-04 Thread Peter Otten
C Smith wrote: > I meant for example: > list1 = [1,2,3] > list2 = [3,4,5] > > newList = list1 + list2 > > versus > > for x in list2: >list1.append(x) > > Which is the preferred way to add elements from one list to another? None of the above unless you need to keep the original list1. Use

Re: [Tutor] append vs list addition

2014-05-04 Thread Steven D'Aprano
On Sun, May 04, 2014 at 09:51:17AM -0400, C Smith wrote: > Sorry. > > I meant for example: > list1 = [1,2,3] > list2 = [3,4,5] > > newList = list1 + list2 This creates a new list, containing the same items as list1 and list2. > versus > > for x in list2: > list1.append(x) This can be writ

Re: [Tutor] append vs list addition

2014-05-04 Thread C Smith
Sorry. I meant for example: list1 = [1,2,3] list2 = [3,4,5] newList = list1 + list2 versus for x in list2: list1.append(x) Which is the preferred way to add elements from one list to another? On Sun, May 4, 2014 at 7:36 AM, Dave Angel wrote: > C Smith Wrote in message: >> >> > I had alw

Re: [Tutor] append vs list addition

2014-05-04 Thread Dave Angel
C Smith Wrote in message: > > I had always assumed that append() was more efficient, but some recent discussions seem to point at that it is the same as append(). Which is preferable and why? Please be more explicit, preferably with example code. list.append and list.__add__ don't even do th

[Tutor] append vs list addition

2014-05-04 Thread C Smith
I had always assumed that append() was more efficient, but some recent discussions seem to point at that it is the same as append(). Which is preferable and why? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https: