Re:PEP 435 Accepted – Adding an Enum type to the Python stan...
by eliben on Friday May 10, 2013 @10:21AM
(#5686318)
What disgusts you about it, in particular?
[ Parent
| on HN ]
Re:PEP 435 Accepted – Adding an Enum type to the Python stan...
by ekimekim on Friday May 10, 2013 @11:56PM
(#5689664)
The fact that it allows whitespace-seperated words. It's just wrong.
It's weird, unnecessary, it just shouldn't be there.
Personally, I would've preferred:
>>> Enum('Example', 'foo', 'bar', 'baz')
(ie. Enum(name, *values))
Re:PEP 435 Accepted – Adding an Enum type to the Python stan...
by eliben on Saturday May 11, 2013 @10:05AM
(#5690601)
That syntax is a bit unusual, but it has the clear advantage of being far less verbose. Consider this:
* The functional API is mostly for short code snippets and experiments in the shell. For real programs, the standard class syntax is preferred and recommended. * namedtuple already uses the same functional API allowing space-separated members, and it's a popular tool in the stdlib. Yes, the first time you run into it it feels a bit odd, but then you get used to it and it's not a big deal.