__getitem__ method on (meta)classes

Ron Garret rNOSPAMon at flownet.com
Wed Mar 16 02:00:47 EST 2005


In article <R4idnd0F2IMyvqrfRVn-1g at comcast.com>,
 Steven Bethard <steven.bethard at gmail.com> 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".

rg



More information about the Python-list mailing list