.title() - annoying mistake

Chris Angelico rosuav at gmail.com
Mon Mar 22 05:49:16 EDT 2021


On Mon, Mar 22, 2021 at 8:26 PM Robert Latest via Python-list
<python-list at python.org> wrote:
>
> Benjamin Schollnick wrote:
> >
> >> I agree with everything you say. Especially the open source part. But
> >> wouldn't you agree that .title() with all its arbitrary specificity to
> >> appear in the very core of a general purpose language is quite an oddity?
> >
> > No, because it book ends the issue.
> >
> > Upper - Converts everything to uppercase Lower - Converts everything to
> > lowercase
> >
> > Title - Covers the cases in-between upper/lower.
>
> My only issue is that I completely fail to see how this function would be
> useful enough to warrant the inclusion into the *core* of a general-purpose
> language, including its misleading name. The fact that the function's behavior
> is correctly documented doesn't make its very existence less bewildering to me.
> Consider this function:
>
> def add_seventeen(n): '''Return n with 16.8 added''' return n + 16.8
>
> It's like .title(): It does almost the thing its name suggests, it is correctly
> documented, it is useful to anybody who happens to want 16.8 added to numbers,
> and it might erroneously be used by someone who wants exactly 17 added and
> didn't bother to read the docs.

If you still, after all these posts, have not yet understood that
title-casing *a single character* is a significant thing, then please
do not continue to complain about language design. Without this
method, how do you correctly title-case one character? What do you
use? upper()? lower()? casefold()?

> BTW I have no beef with the person who invented .title() nor with anybody who
> uses it. I know that everybody can join the Python development community and
> propose the removal of .title() and the inclusion of add_seventeen(). That
> said, I doubt that .title() would make it into Python today if it weren't there
> already. I'm having fun with this.
>

I'm glad you're having fun, because being wrong can be a lot of unfun sometimes.

I'm done arguing with you. You're a brick wall and you refuse to
comprehend Unicode. The method was not invented for ASCII.

ChrisA


More information about the Python-list mailing list