Re: (rant) Yet another intro page suggestion
- Posted by Spock Dec 03, 2017
- 1279 views
_tom said...
Let's try to change 'Henny' to 'Penny' and see what happens: >>> name = 'Henny' >>> name[0] = 'P' Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: 'str' object does not support item assignment
I know nothing about Python but couldn't the 'str' class be updated to include element assignment? It seems ridculous that it is not available at the fundamental level.
EDIT:
>>> b = bytearray('abc0efg') >>> b[3] = 'd' >>> 'abcdefg'
Apparently in Python strings are "inmutable" [whatever that means..] but bytearrays are not..
Spock