On Mon, May 6, 2013 at 12:46 PM, Glenn Linderman <v+pyt...@g.nevcal.com> wrote: > Sadly, once the Enums are defined, there is to be no way to subclass them to > add functionality, like producing a NamedInt result from operations on them.
That rule is enforced by the metaclass, so... ;) Custom metaclasses are amazingly powerful, the trick is to deploy their power judiciously, such that people can use the custom classes associated with them without getting confused. SQL Alchemy, Django and other frameworks do this quite well, but it *does* create subsections of the type hierarchy which don't play well with others (for example, having the same class be both an SQL Alchemy Table definition and a Django Model definition probably isn't going to work). Enums are the same - they carve out a subtree in the type hierarchy that *doesn't* behave the same as the standard tree anchored directly on type. This *is* going to cause conflicts with meta-tools that only handle ordinary types - the trick is that the cause of the problem (a custom metaclass) is also the solution (a custom metaclass derived from enum.enum_type). Cheers, Nick. -- Nick Coghlan | ncogh...@gmail.com | Brisbane, Australia _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com