Modify a string's value

MRAB google at mrabarnett.plus.com
Tue Jul 15 18:17:43 EDT 2008


On Jul 15, 3:06 pm, Ben Finney <bignose+hates-s... at benfinney.id.au>
wrote:
> s0s... at gmail.com writes:
> > I've heard that a 'str' object is immutable. But is there *any* way to
> > modify a string's internal value?
>
> If there were, it would not be immutable. The 'str' type has only
> immutable values.
>
> You could implement your own string type, and have it allow mutable
> values. You'd have to take care of creating those values explicitly,
> though.
>
You could write a C extension which modifies strings, but that would
be a Bad Idea.



More information about the Python-list mailing list