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

Devin Jeanpierre jeanpierreda at gmail.com
Tue Jul 5 00:31:35 CEST 2011


On Mon, Jul 4, 2011 at 6:18 PM, Chris Rebert <pyideas at rebertia.com> wrote:
> Why does it accept nested tuples in the first place for that matter?

Whoops, that was news to me too.

Apparently it's so that if you have code that does isinstance(foo,
bar) you can do isinstance(foo, (bar, baz)) no matter what bar is.
It's the only way to do this generically given that isinstance must
accept both types and collections of types.

Devin



More information about the Python-ideas mailing list