In article <[EMAIL PROTECTED]>,
 Steven Bethard <[EMAIL PROTECTED]> wrote:

> Ron Garret wrote:
> > In article <[EMAIL PROTECTED]>,
> >  Steven Bethard <[EMAIL PROTECTED]> wrote:
> > 
> >>>Yeah, except I actually left out one thing:  I also want type(v)==e1.
> >>
> >>Why?  In Python usually you rely on duck-typing and not explicit type 
> >>checks.  What is it that you're trying to gain by asserting type(v) == e1?
> > 
> > Clarity.  I want to be able to distinguish a member of an enumeration 
> > from a string or an integer for the same reason one would want to 
> > distinguish 123 from "123".
> 
> So then you don't necessarily need that type(v) == e1, you just need 
> type(v) != str.  How about:

[xnip]

That's not bad.  This conflates all enumerated items into a single 
namespace whereas the metaclass solution makes each enumeration its own 
namespace.  For example:

plumbers = enum['Fred','John','Bill']
electricians = enum['Fred','Jake','Lester']

Using a metaclass allows you to distinguish Fred the plumber from Fred 
the electrician.  But that may or may not be what one actually wants.

Must sleep on it.

rg
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to