2.2 features

Guido van Rossum guido at zope.com
Tue Jul 31 15:04:12 EDT 2001


>     Skip> How about 'x in type' as a shorthand for 'issubclass(x, type)' if
>     Skip> x is a type or class instead of an instance?
> 
>     Guido> No, that would be ambiguous.  A subclass is not an instance.  A
>     Guido> class or type represents a set of instances, so 'in' is justified
>     Guido> in a sense.
> 
> I guess I'm confused, but if isinstance(x, type) is true isn't
> issubclass(x.__class__, type) also true?

You are indeed confused. :)

Seems you confuse isinstance(x, y) with issubclass(x, y).  These are
very different.  x in y can map to at most one of these (for y a type
object).

--Guido van Rossum (home page: http://www.python.org/~guido/)




More information about the Python-list mailing list