Message195205
I think IntEnum should act like a str for format() purposes. After all, having a useful string representation is a prime reason it exists. If you want it to act like a str() sometimes, and an int() at others, you're going to have to parse the format specifier and figure out what to do. It might be as easy as:
def __format__(self, fmt):
if len(fmt) >= 1 and fmt[-1] in 'oOxXdD':
# treat like an int
return format(self.value, fmt)
else:
# treat like a string
format(str(self), fmt)
But I haven't completely thought it through or tested it.
Or, couldn't we just say it's always str, and if you want to treat it like an int then use .value? |
|
Date |
User |
Action |
Args |
2013-08-14 19:34:13 | eric.smith | set | recipients:
+ eric.smith, barry, eli.bendersky, ethan.furman, serhiy.storchaka |
2013-08-14 19:34:13 | eric.smith | set | messageid: <1376508853.21.0.680026839315.issue18738@psf.upfronthosting.co.za> |
2013-08-14 19:34:13 | eric.smith | link | issue18738 messages |
2013-08-14 19:34:13 | eric.smith | create | |
|