You can even get closer, but it is NOT recommended

class foostr(str):
     def plural (self):
        if self.value[-1] in "sz":
            return self.value + "es"
        else:
            return self.value + "s"


#ugly hack
setattr(__builtins__, "str", foostr)

print str("apple").plural()

# this however does not work
# print "apple".plural()

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to