Talk:Python Programming/Sequences

Terminology Confusion
So is it a list or an array? What is the correct term, and how interchangeable are they? I'm no expert at Python; quite to the contrary; I'm a beginner. So I find it just a little hard to understand when the terminology is mixed without explanation.

It is a list. Python has arrays, in the array module, and it means another thing. This chapter needs serious work. —Preceding unsigned comment added by 201.80.72.200 (discuss • contribs)

Yet Another Terminology Confusion
The set data structure is called an unordered collection of distinct hashable values. Why call it unordered when every input value is insertet sorted and checked for duplicity? I'm new to python myself and this really confuses me. Even in the Python doku it is called unordered.
 * Values are checked for duplicity but I am curious why you believe they are sorted. I don't know sets myself, although I am reasonably fluent in Python. --Jesdisciple (talk) 18:28, 15 May 2010 (UTC)

Slicing
I notice that slicing was reserved for special "rabbit trail" pages, i.e. sections which aren't in the standard progression of chapters. As strings were also left unmentioned, I added them with an explanation of string slicing and inserted list slicing into that section. I can understand why slicing might be considered a more advanced topic, but it is also a fairly fundamental one. How much should we mention in the tutorial and how much in the rabbit trails (appendices in the printed-book tradition)? --Jesdisciple (talk) 18:26, 15 May 2010 (UTC)

Indexes
Which version is better? A friend told me the first is more confusing but I disagree.

-- --


 * Indexes are numbered from 0 to n-1 where n is the number of items (or characters), and they are positioned between the items:

H e  l  l  o ,  _  w  o  r  l  d  ! 0 1  2  3  4  5  6  7  8  9 10 11 12
 * The item which comes immediately after an index is the one selected by that index. Negative indexes are counted from the end of the string:


 * But in Python, the colon : allows the square brackets to take as many as two numbers. For any sequence which only uses numeric indexes, this will return the portion which is between the specified indexes.  This is known as "slicing," and the result of slicing a string is often called a "substring."

-- --


 * Indexes are numbered from 0 to n-1 where n is the number of items (or characters):

H e  l  l  o ,  _  w  o  r  l  d  ! 0 1  2  3  4  5  6  7  8  9 10 11 12
 * Negative indexes are subtracted from the length of the string:


 * But in Python, the colon : allows the square brackets to take as many as two numbers. For any sequence which only uses numeric indexes, this will return all items from the first index up to but not including the last.  This is known as "slicing," and the result of slicing a string is often called a "substring."

-- --

--Jesdisciple (talk) 03:41, 16 May 2010 (UTC)