A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2001-April/109227.html below:

__sub__ for string

__sub__ for string __sub__ for stringRikard Bosnjakovic bos 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 reason
for that, and not the "Go C++ if you want to do shit like that" that I
got on #python.

I mean, it wasn't much code:

import UserString

class 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: 1158217

Anyone sending unwanted advertising e-mail to my address will be
charged $250 for network traffic and computing time. By extracting my
address from this message or its header, you agree to these terms.

More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4