Why don't stringobjects have methods?

Tommy Burnette (tnb2d@banyan.cs.virginia.edu)
Thu, 31 Mar 1994 16:29:28 GMT

MY FIRST QUESTION: We all voted FOR the comp.lang.python newsgroup,
no? Then why is all Python traffic still going to the mailing list
and none to the newsgroup? We certainly can't let ourselves be
daunted by these idiots who don't know the difference between the
comp.lang and the alt.fandom groups.

MY REAL QUESTION: Why do stringobjects not have methods? We have
listobjects that have their own methods so that I can say:

[1, 3, 2].sort()

or:

[1, 2].append(3)

But if I want to do similar operations on stringobjects I have to
import string or strop and pass my strings through these functions.
Why? Why can't I just say:

message = 'get down get'.append(' funky')

I understand that strings are immutable, but is that necessarily the
right thing? I'll often tack things on to the end of a string with:

string = string + char

and this goes and creates a new string object that is the combination
of the first string and the new char. Wouldn't it be more efficient
to simply add the char onto the end of the original string? I
understand I'm poking at a pedagogical hornet's nest here with the
mutable vs. immutable argument (see the socratic discussion concerning
lists and tuples, right?) but could someone please explain it to me
again?

AND ANOTHER THING: Why do the listobject methods always return None?
It would be more useful if they returned the listobject that resulted
from the method call. That way I could chain operations together like
so:

mylist = [1, 2, 3].reverse().append(0).reverse()

and mylist would == [0, 1, 2, 3]. Is there a reason this would be a
bad thing? the methods have to return SOMETHING, right? How about
something a little more useful than None, eh?

-- 
					-------> Tommy.

"Subvert the parental paradigm - Refuse Birth."