This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eric.smith
Recipients Hervé Cauwelier, eric.smith, r.david.murray
Date 2010-12-09.16:53:52
SpamBayes Score 0.00020238798
Marked as misclassified No
Message-id <1291913633.78.0.620278175237.issue10660@psf.upfronthosting.co.za>
In-reply-to
Content
I agree with David.

Here's an example of using such a subclass. It extends the format string for strings to begin with an optional 'u' or 'l':
-----------------------
class U(str):
    def __format__(self, fmt):
        if fmt[0] == 'u':
            s = self.upper()
            fmt = fmt[1:]
        elif fmt[0] == 'l':
            s = self.lower()
            fmt = fmt[1:]
        else:
            s = str(self)
        return s.__format__(fmt)

name = 'Hervé Cauwelier'

print('{0:u*^20} {0:l*^20} {0:*^20}'.format(U(name)))
-----------------------

It produces:
**HERVÉ CAUWELIER*** **hervé cauwelier*** **Hervé Cauwelier***
History
Date User Action Args
2010-12-09 16:53:53eric.smithsetrecipients: + eric.smith, r.david.murray, Hervé Cauwelier
2010-12-09 16:53:53eric.smithsetmessageid: <1291913633.78.0.620278175237.issue10660@psf.upfronthosting.co.za>
2010-12-09 16:53:52eric.smithlinkissue10660 messages
2010-12-09 16:53:52eric.smithcreate