[New-bugs-announce] [issue1614] bug in string method "title"

Bob Helmbold report at bugs.python.org
Thu Dec 13 19:06:37 CET 2007


New submission from Bob Helmbold:

Summary: "title" method of string objects does not 
   handle contractions and possessives correctly.
See the following short program and its results for examples.
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
"""
Test of string method 'capitalize'
"""

stringList=["we're",
            "you're",
            "they're",
            "i've",
            "we've",
            "you've",
            "they've",
            "can't",
            "won't",
            "doesn't",
            "haven't",
            "daren't",
            "shouldn't",
            "weren't",
            "wasn't",
            "i'm"
            ]

for item in stringList:
    n=len(item)
    spaces=' '*(12-n)
    itemTitled = item.title()
    isATitle = itemTitled.istitle()
    print "%s -> %s%s is title=%s" %(item, spaces, itemTitled, isATitle)

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Results in:
we're ->        We'Re is title=True
you're ->       You'Re is title=True
they're ->      They'Re is title=True
i've ->         I'Ve is title=True
we've ->        We'Ve is title=True
you've ->       You'Ve is title=True
they've ->      They'Ve is title=True
can't ->        Can'T is title=True
won't ->        Won'T is title=True
doesn't ->      Doesn'T is title=True
haven't ->      Haven'T is title=True
daren't ->      Daren'T is title=True
shouldn't ->    Shouldn'T is title=True
weren't ->      Weren'T is title=True
wasn't ->       Wasn'T is title=True
i'm ->          I'M is title=True

----------
components: Interpreter Core
messages: 58544
nosy: ElGordo
severity: normal
status: open
title: bug in string method "title"
type: behavior
versions: Python 2.5

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1614>
__________________________________


More information about the New-bugs-announce mailing list