Re: (rant) Yet another intro page suggestion

new topic     » goto parent     » topic index » view thread      » older message » newer message
_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

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu