[New-bugs-announce] [issue10660] format() to lower and uppercase

Hervé Cauwelier report at bugs.python.org
Thu Dec 9 16:33:42 CET 2010

New submission from Hervé Cauwelier <herve at itaapy.com>:

Hexadecimals can be formatted to lower and uppercase:

>>> '{0:x}'.format(123)
>>> '{0:X}'.format(123)

I would like the same thing for strings:

>>> '{0.lastname:u} {0.firstname}'.format(user)
'DOE John'

I first thought using "S" for uppercase, but "s" is not available for lowercase. So I thought about "u" and "l".

The alternative is to write:

>>> '{0} {1}'.format(user.lastname.upper(), user.firstname)
'DOE John'

But I find it less compact and elegant.

components: Interpreter Core
messages: 123684
nosy: Hervé Cauwelier
priority: normal
severity: normal
status: open
title: format() to lower and uppercase
type: feature request
versions: Python 2.7

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list