Message123686
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*** |
|
Date |
User |
Action |
Args |
2010-12-09 16:53:53 | eric.smith | set | recipients:
+ eric.smith, r.david.murray, Hervé Cauwelier |
2010-12-09 16:53:53 | eric.smith | set | messageid: <1291913633.78.0.620278175237.issue10660@psf.upfronthosting.co.za> |
2010-12-09 16:53:52 | eric.smith | link | issue10660 messages |
2010-12-09 16:53:52 | eric.smith | create | |
|