Eric Smith <e...@trueblade.com> added the comment: 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*** ---------- nosy: +eric.smith _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue10660> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com