better way than: myPage += 'more html' , ...
Oren Tirosh
oren-py-l at hishome.net
Mon Jun 30 12:01:21 EDT 2003
On Thu, Jun 26, 2003 at 10:30:21AM +1000, Delaney, Timothy C (Timothy) wrote:
> import cStringIO as StringIO
>
> # Subclass of str so that it can be used nearly anywhere that requires a real
> # string.
>
> class MutableString (str):
...
Making it a subclass of str doesn't do what you want. Lots of places in the
C code access the string buffer directly (for performance) instead of going
through the __str__ method. They will all get the value the string had when
it was created rather than its current value.
There is currently no way to implement a true replacement of the str type in
Python code. Even an extension type is somewhat limited in its ability to
emulate a string.
Oren
More information about the Python-list
mailing list