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

Amaury Forgeot d'Arc amauryfa at gmail.com
Tue Jul 5 00:50:51 CEST 2011


2011/7/5 Chris Rebert <pyideas at rebertia.com>:
> On Mon, Jul 4, 2011 at 2:55 PM, Amaury Forgeot d'Arc <amauryfa at gmail.com> wrote:
>> 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)))
>
> That doesn't mean it has to necessarily accept other nested
> containers; tuples can be left as a special case for backward
> compatibility.
> Why does it accept nested tuples in the first place for that matter?

All this has already been discussed:
http://mail.python.org/pipermail/python-list/2009-January/1188226.html

-- 
Amaury Forgeot d'Arc



More information about the Python-ideas mailing list