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.22:22:18
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <520C030B.6060105@trueblade.com>
In-reply-to <520C00E5.1000804@stoneleaf.us>
Content
>> In order to avoid that logic, and cause more format specifiers to result in str-like behavior, we'll need to implement an __format__ somewhere (IntEnum, I guess) that makes the "int or str" decision.
> 
> If this is the way format is supposed to work, then I'll add __format__ to IntEnum with simple logic that says if not 
> letter format code is present, use string formatting, otherwise use int formatting.  

Yes, that's exactly how it's supposed to be used, and why __format__
exists at all.

> That should be future proof.

Agreed.

It does mean that a few things that look like int format specifiers
won't be, but I don't think it's a big loss.

For example, '+' only makes sense on an int, but with your proposal it
would be a str format specifier:

>>> format(42, '+')
'+42'
>>> format('42', '+')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: Sign not allowed in string format specifier

Again, I don't think any of these would be a big deal. But it does mean
that there are places that could take an int that can't take an IntEnum.
History
Date User Action Args
2013-08-14 22:22:18eric.smithsetrecipients: + eric.smith, barry, eli.bendersky, ethan.furman, serhiy.storchaka
2013-08-14 22:22:18eric.smithlinkissue18738 messages
2013-08-14 22:22:18eric.smithcreate