Movatterモバイル変換
[0]ホーム
__sub__ for string
Rikard Bosnjakovicbos at hack.org
Fri Apr 13 05:05:31 EDT 2001
I hope I can get a better answer here:Why isn't __sub__ defined for the internal strings? I want a good reasonfor that, and not the "Go C++ if you want to do shit like that" that Igot on #python.I mean, it wasn't much code:import UserStringclass mystr(UserString.UserString): def __init__(self, data=""): self.data = data def __sub__(self, other): return self.data.replace(other, "")>>> s = mystr("foo bar foo foo foo bar")>>> s - "foo"' bar bar'-- Rikard Bosnjakovic -http://bos.hack.org/cv/ - ICQ: 1158217Anyone sending unwanted advertising e-mail to my address will becharged $250 for network traffic and computing time. By extracting myaddress from this message or its header, you agree to these terms.
More information about the Python-listmailing list
[8]ページ先頭