Tuple arg for "classinfo" in isinstance: what does it mean?
Erik Max Francis
max at alcyone.com
Mon Dec 9 17:19:44 EST 2002
Parzival Herzog wrote:
> So, from this, I know I am allowed to supply a tuple, but I have no
> idea at
> all what such
> a tuple argument means to the result of isinstance.
>
> Can anyone supply the semantics? If you can, would you please tell me
> the
> source reference for your information?
Seems pretty clear that the meaning is that if a tuple (or a tuple of
tuples, etc.) is passed in, isinstance will return true if any of the
non-tuple objects match:
>>> isinstance(2, str)
0
>>> isinstance(2, int)
1
>>> isinstance(2, (int, str))
1
>>> isinstance(2, (int, (str,)))
1
In other words, passing tuples to isinstance is functionally equivalent
to multiple calls to isinstance with each element, chained together by
or.
--
Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
__ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/ \ I want to know God's thought; the rest are details.
\__/ Albert Einstein
CSBuddy / http://www.alcyone.com/pyos/csbuddy/
A Counter-Strike server log file monitor in Python.
More information about the Python-list
mailing list