why?

dsavitsk dsavitsk at e-coli.net
Mon Dec 2 18:41:20 EST 2002


from
http://www.python.org/doc/current/tut/node7.html#SECTION00730000000000000000
0

"Tuples, like strings, are immutable: it is not possible to assign to the
individual items of a tuple (you can simulate much of the same effect with
slicing and concatenation, though). It is also possible to create tuples
which contain mutable objects, such as lists."

"sami sieranoja" <sami.sieranoja at pp.inet.fi> wrote in message
news:20021203003514.2abb22e8.sami.sieranoja at pp.inet.fi...
> Hi!
>
> Why does this happen:
>
> >>> doing = ['a','b','c']
> >>> doing[1] = ('b','c')
> >>> doing[1][0]
> 'b'
> >>> doing[1][0] = 'i'
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> TypeError: object doesn't support item assignment
> >>>
>
> Why can't I change that value from 'b' to 'i' ?  Why?
>
>
> -Sami





More information about the Python-list mailing list