[Python-ideas] Allow isinstance second argument to be a set of types

Greg Ewing greg.ewing at canterbury.ac.nz
Fri Jul 8 03:18:55 CEST 2011


Michael Foord wrote:
> The point is 
> that as Accompalice (the type) is an instance of Evil and is therefore 
> an iterable type. So if isintance naively iterated over *anything 
> iterable* it would attempt to iterate over Accomplice.

But if it checks whether something is a type first, it won't
get as far as trying to iterate over it.

This example illustrates that it's possible to create an
object that is ambiguous with respect to the proposed API.
But it's a case that is unlikely to arise in practice,
so I think resolving it using the rule that type-ness
takes precedence over iterable-ness is a reasonable
solution.

-- 
Greg




More information about the Python-ideas mailing list