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

Amaury Forgeot d'Arc amauryfa at gmail.com
Mon Jul 4 23:55:43 CEST 2011


2011/7/4 Michael Foord <fuzzyman at gmail.com>:
>> > Arbitrary iterables, arbitrarily nested...
>> > beware of objects which are also their first element, like str('a')...
>>
>> Ouch. I guess that shoots the proposal dead in the water, then.
>>
>
> Why? Iteration doesn't imply recursing into contained iterators.

isinstance already accept nested tuples:

assert isinstance(1, (str, (int, float)))

-- 
Amaury Forgeot d'Arc



More information about the Python-ideas mailing list