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

Devin Jeanpierre jeanpierreda at gmail.com
Mon Jul 4 23:46:36 CEST 2011


On Mon, Jul 4, 2011 at 5:08 PM, Antoine Pitrou <solipsis at pitrou.net> wrote:
>> 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.

Wasn't the suggestion only for flat iterables, like {int, float,
complex}, rather than nested iterables?
I'm ambivalent, as long as the implementation is careful to make sure
one can still use isinstance on classes like these:
 class WeirdMetaclass(type):
 def __iter__(self):
 yield 1
 class MyObject(metaclass=WeirdMetaclass):
 pass
It still feels a little dirty though, to have to pick between options
that are not mutually exclusive.
Devin


More information about the Python-ideas mailing list

AltStyle によって変換されたページ (->オリジナル) /