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 barry, eli.bendersky, eric.smith, ethan.furman, serhiy.storchaka
Date 2013-08-14.19:34:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1376508853.21.0.680026839315.issue18738@psf.upfronthosting.co.za>
In-reply-to
Content
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?
History
Date User Action Args
2013-08-14 19:34:13eric.smithsetrecipients: + eric.smith, barry, eli.bendersky, ethan.furman, serhiy.storchaka
2013-08-14 19:34:13eric.smithsetmessageid: <1376508853.21.0.680026839315.issue18738@psf.upfronthosting.co.za>
2013-08-14 19:34:13eric.smithlinkissue18738 messages
2013-08-14 19:34:13eric.smithcreate