4 ms·
The only similarity is the signature; semantics are completely unrelated.
by reinhardt 13y ago
The only similarity is the signature; semantics are completely unrelated.
- mixmastamyk 13y agoI guess I'm looking for a usecase that namedtuple (or set...) doesn't support. Here's one example: http://pythonpath.wordpress.com/2012/01/26/python-enum-with-namedtuple/ http://pythonpath.wordpress.com/2012/01/26/python-enum-with-...
- shoo 13y agoin that example the values of the enumerated constants are simply integer values, they do not have their own type. so there is nothing stopping you comparing values from two unrelated enumerations, and getting a nonsensical True or False result, instead of a TypeError.
- mixmastamyk 13y agoI suppose that's true and theoretically useful. I don't find myself coding nonsense very often, but python has not been a language that gives much support (or is appropriate) to use cases that can't tolerate any. I now see some good uses for Enum, but (with a skeptical eye to additions) I believe that the reasons to keep the language/libs small are equally important.