Python 3 isinstance

John Machin sjmachin at
Thu Jan 15 06:10:27 CET 2009

On Jan 15, 2:03 pm, "Lambert, David W (S&T)" <Lamber... at>
> Overly terse.  I do mean that this is illegal:
> isinstance(s, {str, bytes})
> tuples have order, immutability, and the possibility of repeat items.

In the anticipated/usual use case (the type/class names are hard-
* order is a very mild plus (you can list them in descending order of
(imagined) probability)
* immutability is not a problem
* the number of items is not likely to be so large that duplicate
entries would creep in

> A set is most reasonable in a mathematical sense.

This is true -- distinguishing carefully between "most reasonable" and
"the most reasonable" :-)

Do you actually have a use case for dynamically assembling a
collection of classes/types for use with isinstance(), or are you
propelled solely by mathematical reasonableness?


More information about the Python-list mailing list