On Sat, Nov 27, 2010 at 10:55 PM, Rance Hall <ran...@gmail.com> wrote:

> I need to do some case manipulation that I don't see in the documented
> string functions.
>
> I want to make sure that user input meets a certain capitalization
> scheme, for example, if user input is a name, then the first letter of
> each word in the name is upper case, and the rest are lower.
>

So for instance, something like this?

In [3]: badcasename = 'eRic SPAM IDle jr.'

In [4]: badcasename.title()
Out[4]: 'Eric Spam Idle Jr.'

Problems with this approach as I see them:
> The built in split function will create undesirable results for names
> that contain suffixes like Jr.  etc.
>

If you want it to behave differently for suffixes, I'm not sure how to do
that...


> I'm not entirely sure how to replace the string with an uppercase
> first letter on a per word basis.
>

mystring = mystring.title()


> Whats the "right" way to do something like this?


gaining more familiarity with the builtin functions ;)

HTH,
Wayne
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to