On 5/5/2013 9:51 PM, Nick Coghlan wrote:
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... ;)

Sure.  But:

stdlib contains:
  Enum (with subclass prohibiting metaclass)
  APIs with flags
(assumed, in time) Enums defining the flag values (complete with enforcement by the metaclass)

user code:
have to recreate all the Enums defining flag values using custom enum_type metaclass.

Seems like FlagEnum might be a a good thing to invent before (re-)defining Enums for all the flag values (that's what I'm after in combining NamedInt and Enum, really).

I suppose that a mere mortal could simply define a subclass of int that keeps track of expressions during arithmetic... using __name__ attributes of its operands if they exist, and as long as the mere mortal remembered to use it, it would achieve the same goal. But having that built in with the flag value definitions would assure that it was available for everyone, all the time.
_______________________________________________
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

Reply via email to