[issue25432] isinstance documentation: explain behavior when type is a tuple

2015-10-28 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Doing this now.

--
assignee: docs@python -> terry.reedy

___
Python tracker 

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



[issue25432] isinstance documentation: explain behavior when type is a tuple

2015-10-28 Thread Terry J. Reedy

Changes by Terry J. Reedy :


--
resolution:  -> fixed
stage: needs patch -> resolved
status: open -> closed

___
Python tracker 

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



[issue25432] isinstance documentation: explain behavior when type is a tuple

2015-10-28 Thread Roundup Robot

Roundup Robot added the comment:

New changeset aaf8a25133ff by Terry Jan Reedy in branch '2.7':
Issue #25432: Explain isinstance behaviour when type is a tuple.
https://hg.python.org/cpython/rev/aaf8a25133ff

New changeset 8b1418e5dcc8 by Terry Jan Reedy in branch '3.4':
Issue #25432: Explain isinstance behaviour when type is a tuple.
https://hg.python.org/cpython/rev/8b1418e5dcc8

--
nosy: +python-dev

___
Python tracker 

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



[issue25432] isinstance documentation: explain behavior when type is a tuple

2015-10-26 Thread feliep

feliep added the comment:

I think that the following part could replace the part of the other text that's 
between ###. It's more objective and easier to understand. 

classinfo may could be a tuple of type objects, or may contains others tuples 
that contains type objects (other sequence types are not accepted).

Return true if the object argument is an instance of the classinfo argument, or 
of a (direct, indirect or virtual) subclass thereof. If object is not an object 
of the given type, the function always returns false. ### 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). ### If 
classinfo is not a type or tuple of types and such tuples, a TypeError 
exception is raised.

What do you think?

--
nosy: +felipevolpone

___
Python tracker 

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



[issue25432] isinstance documentation: explain behavior when type is a tuple

2015-10-26 Thread R. David Murray

R. David Murray added the comment:

The fact that nested tuples are accepted is just bizarre, IMO :(.

It could say something like "If classinfo is a (possibly nested) list of types, 
return True if any of the types match."

--

___
Python tracker 

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



[issue25432] isinstance documentation: explain behavior when type is a tuple

2015-10-26 Thread Felipe Volpone

Felipe Volpone added the comment:

r.david.murray: I liked your way.

--

___
Python tracker 

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



[issue25432] isinstance documentation: explain behavior when type is a tuple

2015-10-26 Thread R. David Murray

R. David Murray added the comment:

Sure, that's fine with me.  I was trying to minimize words, but clarity is good.

--

___
Python tracker 

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



[issue25432] isinstance documentation: explain behavior when type is a tuple

2015-10-26 Thread Terry J. Reedy

Terry J. Reedy added the comment:

David, if you are suggesting that the initial negative clause of "If classinfo 
is not a class (type object)" is not needed, I agree.  If classinfo is a tuple, 
is is not a class.  'list of types' has to be 'tuple of types'. I think 'match' 
needs to be expanded to 'is an instance of'. How about

"If classinfo is a tuple of type objects (or recursively, other such tuples), 
return true if object is an instance of any of the types.

This leaves out the left to right ordering of the tests, but I think that is 
implied by how Python generally works.  Short circuiting certainly is.

--

___
Python tracker 

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



[issue25432] isinstance documentation: explain behavior when type is a tuple

2015-10-25 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Perhaps add after third sentence (ending with "not accepted)."), "If classinfo 
is a tuple, isinstance(x, classinfo) is the same as any(isinstance(x, C) for C 
in flatten(classinfo))".

--
nosy: +terry.reedy
stage:  -> needs patch
title: isinstance documentation doesn't explain what happens when type is tuple 
-> isinstance documentation: explain behavior when type is a tuple
type:  -> enhancement
versions: +Python 3.4, Python 3.5

___
Python tracker 

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