Problems with string and lists (searching and replaceing)

jblazi jblazi at hotmail.com
Sat Sep 20 15:08:40 EDT 2003


"Anton Vredegoor" <anton at vredegoor.doge.nl> schrieb im Newsbeitrag
news:bkhnpn$hgc$1 at news.hccnet.nl...
> >Do I oversee something?
>
> Yes, UserString. The documentation is a bit sparse, but reading the
> module itself provides additional information. Below is a quick test
> script.
>
> from UserString import MutableString
>
> def test():
>     s = MutableString("helo world")
>     print s
>     x = 'helo'
>     y = 'hello'
>     i = s.find(x)
>     s[i:i+len(x)] = y
>     print s
>
> if __name__=='__main__':
>     test()
>
> #output:
> #helo world
> #hello world

Thx.
It would be quite diffcult to explain this akward procedure to beginners.
especially when they see that this can be done so simply in C.
It seems that I have stumbled upon one of the few cases when Python is
cumbersome and difficult to use.

JB






More information about the Python-list mailing list