[issue37307] isinstance/issubclass doc isn't clear on whether it's an AND or an OR.

2019-06-21 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
versions:  -Python 3.5, Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37307] isinstance/issubclass doc isn't clear on whether it's an AND or an OR.

2019-06-16 Thread SilentGhost


SilentGhost  added the comment:

It's the same behaviour as for isinstance, could be enough to add "classinfo is 
treated as in isinstance call" to avoid duplication. This would also solve 
short-cutting imprecision.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37307] isinstance/issubclass doc isn't clear on whether it's an AND or an OR.

2019-06-16 Thread Franklin? Lee


Franklin? Lee  added the comment:

> > It's likely also false that every entry will be checked, since presumably 
> > the function uses short-circuit logic.

> This, however, would be good to verify first.

Verified.
https://github.com/python/cpython/blob/36dcaab7fde5d2e54cdeff5b705b5adcb27726dd/Objects/abstract.c#L2517

It loops through the tuple until it finds success or error.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37307] isinstance/issubclass doc isn't clear on whether it's an AND or an OR.

2019-06-16 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

docstring for issubclass is a bit clear on the behavior


issubclass(cls, class_or_tuple, /)
Return whether 'cls' is a derived from another class or is the same class.

A tuple, as in ``issubclass(x, (A, B, ...))``, may be given as the target to
check against. This is equivalent to ``issubclass(x, A) or issubclass(x, B)
or ...`` etc.

--
nosy: +xtreak

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37307] isinstance/issubclass doc isn't clear on whether it's an AND or an OR.

2019-06-16 Thread Franklin? Lee


Franklin? Lee  added the comment:

My mistake. I selected all versions after checking issubclass for 2.7 and 
several 3.x, but added the isinstance notes later without paying attention to 
versions.

I copied the isinstance text from 3.2 docs. As you said, it's not the current 
text.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37307] isinstance/issubclass doc isn't clear on whether it's an AND or an OR.

2019-06-16 Thread SilentGhost


SilentGhost  added the comment:

> It's likely also false that every entry will be checked, since presumably the 
> function uses short-circuit logic.

This, however, would be good to verify first.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37307] isinstance/issubclass doc isn't clear on whether it's an AND or an OR.

2019-06-16 Thread SilentGhost


SilentGhost  added the comment:

Where are you seeing the text you've quoted for isinstance? You've marked as 
all versions affected, but for the master docs the text for isinstance is 
different and is unambiguous re treatment of tuple classinfo.

I agree with all your points about issubclass

--
nosy: +SilentGhost

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37307] isinstance/issubclass doc isn't clear on whether it's an AND or an OR.

2019-06-16 Thread Franklin? Lee


New submission from Franklin? Lee :

isinstance:
> If classinfo is not a class (type object), it may be a tuple of type objects, 
> or may recursively contain other such tuples (other sequence types are not 
> accepted).

issubclass:
> classinfo may be a tuple of class objects, in which case every entry in 
> classinfo will be checked.

It is unclear from the docs whether
issubclass(bool, (int, float))
should return True (because bool is a subclass of int),
or False (because bool is NOT a subclass of float).
(It returns True.)

It's likely also false that every entry will be checked, since presumably the 
function uses short-circuit logic.

issubclass's doc also doesn't mention the recursive tuple case that 
isinstance's doc has.

--
assignee: docs@python
components: Documentation
messages: 345744
nosy: docs@python, leewz
priority: normal
severity: normal
status: open
title: isinstance/issubclass doc isn't clear on whether it's an AND or an OR.
type: enhancement
versions: Python 2.7, Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com