[Python-Dev] String methods... finally

Ka-Ping Yee ping at lfw.org
Sat Jun 12 10:05:06 CEST 1999

On Fri, 11 Jun 1999, Fredrik Lundh wrote:
> > Two new methods startswith and endswith act like their Java cousins.
> is it just me, or do those method names suck?
> begin?  starts_with?  startsWith? (ouch)
> has_prefix?

I'm quite happy with "startswith" and "endswith".  I mean,
they're a bit long, i suppose, but i can't think of anything
better.  You definitely want to avoid has_prefix, as that
compounds the has_key vs. hasattr issue.

    x[:3] == "foo"

    x[:len(y)] == y

Hmm.  I guess it doesn't save you much typing until y is an
expression.  But it's still a lot easier to read.


More information about the Python-Dev mailing list