In python, string literals are always of type basestring (or str in py3k). Thus, you cannot add methods to string literals. You can create a class that takes a string in the constructor and has methods that can be useful:
MyClass("the string").myfunc()
Of course, then it could probably be argued that you should write a function:
myfunc("the string")
source share