M
Mark Lawrence
That's the title of this little beast
http://www.acooke.org/cute/Pythonssad0.html if anybody's interested.
http://www.acooke.org/cute/Pythonssad0.html if anybody's interested.
That's the title of this little beast
http://www.acooke.org/cute/Pythonssad0.html if anybody's interested.
- you need to repeat the class name (in a string, which your IDE is
unlikely to check)
- the parameters are themselves in a string, which your IDE is
unlikely to parse and provide in auto-complete (they can be separate
strings, in a sequence, but that doesn't really help).
[end quote]
Then maybe you shouldn't be relying on such a lousy IDE then.
Well, perhaps I'm being a tad harsh. After all, it's not like it is a
*feature* that namedtuple *requires* you to include the class name. But
really, it's a trivial inconvenience. Python has much worse, e.g.:
- why aren't my CONSTANTS actually constant?
and yet somehow we survive.
4) Auto-generated enums aren't strings:
That would makes sense (red = 'red'), in that it would display
nicely and is going to provide easy to debug values. So nope.
[end quote]
Missing the point entirely. The *whole point* of enum red is that it WILL
display as 'red', even though it wraps an underlying value of <whatever
arbitrary value Python generates>. So this is a non-issue.
I think Enums will be good addition to the standard library, and I look
forward to dropping support for Python 3.3 so I can rely on them
Let's look at his major criticisms:
1) values aren't automatically generated.
True. So what? That is the *least* important part of enums.
I stopped following the -ideas threads about enums, but IIRC
autogeneration of values was in quite a few of the specs early on. So
you can probably find the arguments against it in the list archives.
FWIW, though, I do like C's autogeneration of enum values - but use it
in only a small proportion of my enums. It's not a terrible loss, but
it is a loss.
ChrisA
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.