Re: [Python-Dev] format, int, and IntEnum

2013-08-21 Thread Ethan Furman
On 08/20/2013 11:15 PM, Ethan Furman wrote: On 08/14/2013 09:27 PM, Nick Coghlan wrote: For enums, I believe they should be formatted like their base types (so !s and !r will show the enum name, anything without coercion will show the value) . I agree. While one of the big reasons for an Enum

Re: [Python-Dev] format, int, and IntEnum

2013-08-20 Thread Ethan Furman
On 08/14/2013 09:27 PM, Nick Coghlan wrote: For enums, I believe they should be formatted like their base types (so !s and !r will show the enum name, anything without coercion will show the value) . I agree. While one of the big reasons for an Enum type was the pretty str and repr, I don't s

Re: [Python-Dev] format, int, and IntEnum

2013-08-15 Thread Ethan Furman
On 08/15/2013 10:44 AM, Eric V. Smith wrote: On 08/15/2013 11:21 AM, Ethan Furman wrote: Given that the !r and !s format codes can be used to get the repr and str of an IntEnum, would it be acceptable to have IntEnum's __format__ simply pass through to int's __format__? And likewise with all mi

Re: [Python-Dev] format, int, and IntEnum

2013-08-15 Thread Eric V. Smith
On 08/15/2013 11:21 AM, Ethan Furman wrote: > Given that the !r and !s format codes can be used to get the repr and > str of an IntEnum, would it be acceptable to have IntEnum's __format__ > simply pass through to int's __format__? And likewise with all mix-in > classes? That helps with str.forma

Re: [Python-Dev] format, int, and IntEnum

2013-08-15 Thread Eric V. Smith
On 08/15/2013 11:06 AM, Nick Coghlan wrote: > On 15 August 2013 05:03, Eric V. Smith wrote: >> On 8/15/2013 12:27 AM, Nick Coghlan wrote: >>> I think Eric is overinterpreting the spec, there. While that particular >>> sentence requires that the empty format string will be equivalent to a >>> plain

Re: [Python-Dev] format, int, and IntEnum

2013-08-15 Thread Eli Bendersky
> This got me thinking when we were discussing it in the issue. It's > plausible that every subclass of builtin types will need to implement > __format__ to act sanely. So maybe we can propose some sort of API (on the > Python level) that makes parsing the format string easy and will not make > cod

Re: [Python-Dev] format, int, and IntEnum

2013-08-15 Thread Eric V. Smith
On Aug 15, 2013, at 11:36 AM, Eli Bendersky wrote: > > > > On Thu, Aug 15, 2013 at 8:15 AM, Eric V. Smith wrote: >> On Aug 15, 2013, at 10:59 AM, Eli Bendersky wrote: >> >>> >>> >>> >>> On Thu, Aug 15, 2013 at 3:03 AM, Eric V. Smith wrote: On 8/15/2013 12:27 AM, Nick Coghlan wrote:

Re: [Python-Dev] format, int, and IntEnum

2013-08-15 Thread Ethan Furman
Given that the !r and !s format codes can be used to get the repr and str of an IntEnum, would it be acceptable to have IntEnum's __format__ simply pass through to int's __format__? And likewise with all mix-in classes? -- ~Ethan~ ___ Python-Dev maili

Re: [Python-Dev] format, int, and IntEnum

2013-08-15 Thread Eli Bendersky
On Thu, Aug 15, 2013 at 8:15 AM, Eric V. Smith wrote: > On Aug 15, 2013, at 10:59 AM, Eli Bendersky wrote: > > > > > On Thu, Aug 15, 2013 at 3:03 AM, Eric V. Smith wrote: > >> On 8/15/2013 12:27 AM, Nick Coghlan wrote: >> > I think Eric is overinterpreting the spec, there. While that particular

Re: [Python-Dev] format, int, and IntEnum

2013-08-15 Thread Eric V. Smith
On Aug 15, 2013, at 10:59 AM, Eli Bendersky wrote: > > > > On Thu, Aug 15, 2013 at 3:03 AM, Eric V. Smith wrote: >> On 8/15/2013 12:27 AM, Nick Coghlan wrote: >> > I think Eric is overinterpreting the spec, there. While that particular >> > sentence requires that the empty format string will

Re: [Python-Dev] format, int, and IntEnum

2013-08-15 Thread Nick Coghlan
On 15 August 2013 05:03, Eric V. Smith wrote: > On 8/15/2013 12:27 AM, Nick Coghlan wrote: >> I think Eric is overinterpreting the spec, there. While that particular >> sentence requires that the empty format string will be equivalent to a >> plain str() operation for builtin types, it is only a r

Re: [Python-Dev] format, int, and IntEnum

2013-08-15 Thread Eli Bendersky
On Thu, Aug 15, 2013 at 3:03 AM, Eric V. Smith wrote: > On 8/15/2013 12:27 AM, Nick Coghlan wrote: > > I think Eric is overinterpreting the spec, there. While that particular > > sentence requires that the empty format string will be equivalent to a > > plain str() operation for builtin types, it

Re: [Python-Dev] format, int, and IntEnum

2013-08-15 Thread Eric V. Smith
On 8/15/2013 12:27 AM, Nick Coghlan wrote: > I think Eric is overinterpreting the spec, there. While that particular > sentence requires that the empty format string will be equivalent to a > plain str() operation for builtin types, it is only a recommendation for > other types. For enums, I believ

Re: [Python-Dev] format, int, and IntEnum

2013-08-14 Thread Glenn Linderman
On 8/14/2013 9:27 PM, Nick Coghlan wrote: I think Eric is overinterpreting the spec, there. While that particular sentence requires that the empty format string will be equivalent to a plain str() operation for builtin types, it is only a recommendation for other types. For enums, I believe t

Re: [Python-Dev] format, int, and IntEnum

2013-08-14 Thread Nick Coghlan
I think Eric is overinterpreting the spec, there. While that particular sentence requires that the empty format string will be equivalent to a plain str() operation for builtin types, it is only a recommendation for other types. For enums, I believe they should be formatted like their base types (s

[Python-Dev] format, int, and IntEnum

2013-08-14 Thread Ethan Furman
From http://bugs.python.org/issue18738: Ethan Furman commented: --> class Test(enum.IntEnum): ... one = 1 ... two = 2 ... --> '{}'.format(Test.one) 'Test.one' --> '{:d}'.format(Test.one) '1' --> '{:}'.format(Test.one) 'Test.one' --> '{:10}'.format(Test.one) ' 1' Eric V. Smith c