[Python-Dev] PEP 435 - requesting pronouncement
pjenvey at underboss.org
Sun May 5 18:50:14 CEST 2013
On May 5, 2013, at 6:44 AM, Ethan Furman wrote:
> On 05/05/2013 03:05 AM, Antoine Pitrou wrote:
>> I still would like to see Nick's class-based API preferred over the
>> functional API:
>> class Season(Enum, members='spring summer autumn'):
>> The PEP doesn't even mention it, even though you got significant
>> pushback on the proposed _getframe() hack for pickling (including
>> mentions that IronPython and Cython may not support it), and nobody
>> seemed to be unhappy with the class-based proposal.
> Agreed that the PEP should mention it.
> -1 on using it.
> We don't need two different ways to use class syntax.
> The functional interface is there for two reasons:
> - to easily create enums dynamically (fairly rare, I'm sure)
> - to easily create enums when prototyping or at the interactive prompt (I'll use it all the time -- it's convenient! ;)
I don't understand, the class based API is perfectly fine for prototyping in the repl.
For dynamic creation, the class API always provides a functional API for free:
types.new_class('Season', (Enum,), dict(values='spring summer autumn'))
It's not convenient, but that doesn't matter because this usage is rare anyway. Certainly much rarer than declarations of auto-numbered enums.
More information about the Python-Dev