why?
Steve Holden
sholden at holdenweb.com
Mon Dec 2 18:16:50 EST 2002
More information about the Python-list mailing list
Mon Dec 2 18:16:50 EST 2002
- Previous message (by thread): why?
- Next message (by thread): why?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"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? > The short answer is "you just can't". One of the fundamental properties of any Python type is whether the values are mutable (can be changed) or immutable (cannot be changed). Strings are immutable, and that is what the error message is saying - that the individual characters in the string cannot be changed. For further enlightenment, consult the FAQ as http://www.python.org/cgi-bin/faqw.py?query=immutable+string&querytype=allke ywords&casefold=yes&req=search regards ----------------------------------------------------------------------- Steve Holden http://www.holdenweb.com/ Python Web Programming http://pydish.holdenweb.com/pwp/ Previous .sig file retired to www.homeforoldsigs.com -----------------------------------------------------------------------
- Previous message (by thread): why?
- Next message (by thread): why?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list