[docs] [issue16437] issubclass doc improvement

Ezio Melotti report at bugs.python.org
Fri Nov 9 00:46:28 CET 2012


Ezio Melotti added the comment:

While this is documented for isinstance, I'm not sure it should be advertised too much, as it seems to me an implementation detail and doesn't seem too useful in practice.

This is a side-effect of the fact that
  isinstance(x, (A, B, ...))
is equivalent to
  isinstance(x, A) or isinstance(x, B) or ...
and therefore
  isinstance(x, (A, (B, C)))
is equivalent to
  isinstance(x, A) or isinstance(x, (B, C))
which in turn is equivalent to
  isinstance(x, A) or (isinstance(x, B) or isinstance(x, C))

While this behavior seems intentional [0], it doesn't seem to be tested [1].  FTR this is supported by PyPy too.

[0]: http://hg.python.org/cpython/file/default/Objects/abstract.c#l2494
[1]: http://hg.python.org/cpython/file/default/Lib/test/test_builtin.py#l704

----------
nosy: +ezio.melotti
type:  -> enhancement

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16437>
_______________________________________


More information about the docs mailing list