This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Fix set.intersection docstring
Type: Stage:
Components: Documentation Versions: Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: belopolsky, georg.brandl, rhettinger, turgon
Priority: normal Keywords: patch

Created on 2009-11-04 16:24 by belopolsky, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
set-intersection-doc.diff belopolsky, 2009-11-04 16:24 Diff to py3k revision 76107
Messages (3)
msg94892 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2009-11-04 16:24
"""
intersection(...)
    Return the intersection of two sets as a new set.
    
    (i.e. all elements that are in both sets.)
"""

Is incorrect because set.intersection takes two or more sets.

Attached patch changes that to

"""
intersection(...)
    Return the intersection of two or more sets as a new set.
    
    (i.e. all elements that are in all sets.)
"""
msg178012 - (view) Author: Juan Benavente Ponce (turgon) Date: 2012-12-23 19:27
set.intersection and frozenset.intersection docstrings are back to the wrong two-sets-only version in Python 3.3 (Python 2.7 is not affected):

"""
intersection(...)
    Return the intersection of two sets as a new set.
    
    (i.e. all elements that are in both sets.)
"""

 The correct docstring should be the one already submitted by Alexander Belopolsky:

"""
intersection(...)
    Return the intersection of two or more sets as a new set.
    
    (i.e. all elements that are in all sets.)
"""

 Thanks everyone for your great work and Merry Christmas!
msg178016 - (view) Author: Juan Benavente Ponce (turgon) Date: 2012-12-23 20:51
Comparing the docstrings with the on-line documentation, I have found that, in addition to the already mentioned issue, the fact that many methods only require the first argument to be a set (or frozenset) object is not mentioned anywhere in the docstrings. Would it be useful if I write here a list of all the cases where this happens, and a possible alternative? An example:

Python 2.7
set.union
current docstring:
"""Return the union of sets as a new set.

(i.e. all elements that are in either set.)"""

possible enhancement:
"""union(set1, *iterables) --> new set

Return a new set with elements from set1 and all the iterables."""

 Would it be a good idea to create a different docstring for the bound method? E.g:

unbound version:
"""union(set1, *iterables) --> new set

Return a new set with elements from set1 and all the iterables."""

bound version:
"""set1.union(*iterables) --> new set

Return a new set with elements from set1 and all the iterables."""

 If writing this list would be useful, please tell me so, and I will do it. Thanks for your time!
History
Date User Action Args
2022-04-11 14:56:54adminsetgithub: 51512
2012-12-23 20:51:25turgonsetmessages: + msg178016
2012-12-23 19:27:28turgonsetnosy: + turgon

messages: + msg178012
versions: + Python 3.3, - Python 2.7, Python 3.2
2009-11-19 01:07:50rhettingersetstatus: open -> closed
resolution: fixed
2009-11-04 16:33:04rhettingersetassignee: georg.brandl -> rhettinger

nosy: + rhettinger
2009-11-04 16:24:33belopolskycreate