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

Guido van Rossum guido at python.org
Wed Jul 6 00:36:30 CEST 2011


FWIW, the restriction to tuples is to avoid burdening the recursive C code
with checks for cycles. Please keep that property.
On Jul 3, 2011 3:47 PM, "Michael Foord" <fuzzyman at gmail.com> wrote:
> Hello all,
>
> Occasionally I build up tuples of types for passing as the second argument
> to isinstance. I've noticed on occasions having duplicates, for example
the
> following code is Python 2 & 3 compatible but results in a duplicate on
one
> of them:
>
> FunctionTypes = (
> # python function
> type(create_autospec),
> # instance method
> type(ANY.__eq__),
> # unbound method
> type(_ANY.__eq__),
> )
>
> It would feel cleaner to me if I could make FunctionTypes a set and use
that
> as the second argument to isinstance. :-)
>
> Michael
>
> --
>
> 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/20110705/45ab43cf/attachment.html>


More information about the Python-ideas mailing list