Re: s.index(x[, i[, j]]) will change the s ?

2009-09-10 Thread Steven D'Aprano
On Wed, 09 Sep 2009 22:00:41 -0700, s7v7nislands wrote: When a negative index is passed as the second or third parameter to the index() method, the list length is added, as for slice indices. I don't understand the mean. the list length is added, why? if it changed, the original will change

Re: s.index(x[, i[, j]]) will change the s ?

2009-09-10 Thread Terry Reedy
Chris Rebert wrote: On Wed, Sep 9, 2009 at 10:00 PM, s7v7nislandss7v7nisla...@gmail.com wrote: snip? I known index() does not modify the sequence itself. my question is so why the doc put the index() method in the mutable sequence types list? Because once upon a time, only lists and not

s.index(x[, i[, j]]) will change the s ?

2009-09-09 Thread s7v7nislands
hi all: what is the s.index() mean? does the index() change the s? In python2.6 doc (6.6.4. Mutable Sequence Types), Note 4: Raises ValueError when x is not found in s. When a negative index is passed as the second or third parameter to the index() method, the list length is added, as for

Re: s.index(x[, i[, j]]) will change the s ?

2009-09-09 Thread r
On Sep 9, 11:00 pm, s7v7nislands s7v7nisla...@gmail.com wrote: hi all:     what is the s.index() mean? does the index() change the s?     In python2.6 doc (6.6.4. Mutable Sequence Types), Note 4: Raises ValueError when x is not found in s. When a negative index is passed as the second or

Re: s.index(x[, i[, j]]) will change the s ?

2009-09-09 Thread Chris Rebert
On Wed, Sep 9, 2009 at 9:00 PM, s7v7nislandss7v7nisla...@gmail.com wrote: hi all:    what is the s.index() mean? does the index() change the s? It tells you the index of the first instance of the given element in the sequence. Or, to quote the docs: s.index(x[, i[, j]]) --- return smallest

Re: s.index(x[, i[, j]]) will change the s ?

2009-09-09 Thread Steven D'Aprano
On Wed, 09 Sep 2009 21:00:20 -0700, s7v7nislands wrote: hi all: what is the s.index() mean? does the index() change the s? It returns the index (position) of its argument in the object s. Have you tried it to see for yourself? ['a', 'b', 'c', 'd'].index('c') # 'c' is in position 2 2

Re: s.index(x[, i[, j]]) will change the s ?

2009-09-09 Thread s7v7nislands
Thanks for your reply! Sorry for my poor english! On Sep 10, 12:33 pm, Chris Rebert c...@rebertia.com wrote: On Wed, Sep 9, 2009 at 9:00 PM, s7v7nislandss7v7nisla...@gmail.com wrote: hi all:    what is the s.index() mean? does the index() change the s? It tells you the index of the first

Re: s.index(x[, i[, j]]) will change the s ?

2009-09-09 Thread tec
s7v7nislands 写道: Thanks for your reply! Sorry for my poor english! On Sep 10, 12:33 pm, Chris Rebert c...@rebertia.com wrote: On Wed, Sep 9, 2009 at 9:00 PM, s7v7nislandss7v7nisla...@gmail.com wrote: hi all: what is the s.index() mean? does the index() change the s? It tells you the index

Re: s.index(x[, i[, j]]) will change the s ?

2009-09-09 Thread Chris Rebert
On Wed, Sep 9, 2009 at 10:00 PM, s7v7nislandss7v7nisla...@gmail.com wrote: snip? I known index() does not modify the sequence itself. my question is so why the doc put the index() method in the mutable sequence types list? Ah, okay. Now I understand your question. I don't know really. I suppose