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

Michael Foord fuzzyman at gmail.com
Mon Jul 4 23:50:44 CEST 2011


On 4 July 2011 22:46, Devin Jeanpierre <jeanpierreda at gmail.com> wrote:

> 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.
>

That's a more reasonable objection for not accepting arbitrary iterables
(although iterable types are a little "specialised").

Michael


>
> Devin
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
>



-- 

http://www.voidspace.org.uk/

May you do good and not evil
May you find forgiveness for yourself and forgive others
May you share freely, never taking more than you give.
-- the sqlite blessing http://www.sqlite.org/different.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20110704/deb1bcb6/attachment.html>


More information about the Python-ideas mailing list