Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to rec.audio.pro
Tobiah Tobiah is offline
external usenet poster
 
Posts: 666
Default Check my understanding.

list.append([1,2]) will add the two element list as the next
element of the list.

list.extend([1,2]) is equivalent to list = list + [1, 2]
and the result is that each element of the added list
becomes it's own new element in the original list.

Is that the only difference?

From the manual:

s.extend(x) | same as s[len(s):len(s)] = x

But: (python 2.5.2)

a

[1, 2, 3]
a[len(a):len(a)] = 4

Traceback (most recent call last):
File "stdin", line 1, in module
TypeError: can only assign an iterable


Also, what is the difference between list[x:x] and list[x]?

a[3:3] = [4]
a

[1, 2, 3, 4]
a[4] = 5

Traceback (most recent call last):
File "stdin", line 1, in module
IndexError: list assignment index out of range



Thanks


** Posted from http://www.teranews.com **
  #2   Report Post  
Posted to rec.audio.pro
Tobiah Tobiah is offline
external usenet poster
 
Posts: 666
Default Check my understanding.

Wrong group.... please ignore!

On Tue, 01 Jul 2008 12:30:22 -0700, Tobiah wrote:

list.append([1,2]) will add the two element list as the next
element of the list.

list.extend([1,2]) is equivalent to list = list + [1, 2]
and the result is that each element of the added list
becomes it's own new element in the original list.

Is that the only difference?

From the manual:

s.extend(x) | same as s[len(s):len(s)] = x

But: (python 2.5.2)

a

[1, 2, 3]
a[len(a):len(a)] = 4

Traceback (most recent call last):
File "stdin", line 1, in module
TypeError: can only assign an iterable


Also, what is the difference between list[x:x] and list[x]?

a[3:3] = [4]
a

[1, 2, 3, 4]
a[4] = 5

Traceback (most recent call last):
File "stdin", line 1, in module
IndexError: list assignment index out of range



Thanks


** Posted from http://www.teranews.com **


** Posted from http://www.teranews.com **
  #3   Report Post  
Posted to rec.audio.pro
Lucky[_2_] Lucky[_2_] is offline
external usenet poster
 
Posts: 5
Default Check my understanding.

Tobiah wrote:

Wrong group.... please ignore!


And I was still working on it!
  #4   Report Post  
Posted to rec.audio.pro
Geoff Geoff is offline
external usenet poster
 
Posts: 2,562
Default Check my understanding.

Lucky wrote:
Tobiah wrote:

Wrong group.... please ignore!


And I was still working on it!


I was going to say "Absolutely !".

geoff


Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Am I understanding this correctly? jaric Pro Audio 17 May 28th 06 05:15 PM
speaker check up check list? apa Pro Audio 8 September 16th 05 03:24 PM
what is wrong in my understanding ??????????????? ranjeet Pro Audio 0 December 25th 04 09:10 AM
what is wrong in my understanding ??????????????? ranjeet Pro Audio 3 December 16th 04 10:43 PM
understanding the dpr-901 xy Pro Audio 4 August 8th 03 05:58 PM


All times are GMT +1. The time now is 09:30 AM.

Powered by: vBulletin
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 AudioBanter.com.
The comments are property of their posters.
 

About Us

"It's about Audio and hi-fi"