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: Separated square brackets will generate a tuple instead of a list.
Type: enhancement Stage: resolved
Components: Documentation Versions: Python 3.8, Python 3.7, Python 3.6, Python 3.4, Python 3.5, Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: docs@python Nosy List: YCmove, berker.peksag, cheryl.sabella, docs@python, r.david.murray
Priority: normal Keywords: patch

Created on 2017-11-22 06:46 by YCmove, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 4498 closed YCmove, 2017-11-22 06:54
Repositories containing patches
https://github.com/YCmove/cpython/commit/8539394cca1fdfa9f988b533ef8b56e1b9681f84
Messages (5)
msg306698 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2017-11-22 07:09
Thank you for your report and for the PR, but I think you misunderstood documentation:

    Using square brackets, separating items with commas: [a], [a, b, c]

The comma is used to show two different lists: a list with one item ``[a]`` *and* a list with three items ``[a, b, c]``, not a tuple with two lists ``[a], [a, b, c]`` (In Python, both ``(1,)`` and ``1,`` create a tuple)
msg306720 - (view) Author: Cheryl Sabella (cheryl.sabella) * (Python committer) Date: 2017-11-22 11:07
Perhaps this is what the YCMove meant?

>>> a = [1], [2, 3, 4]
>>> a
([1], [2, 3, 4])
>>>
msg306724 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2017-11-22 11:37
That's why I mentioned ``[a], [a, b, c]`` in my earlier message.
msg306727 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2017-11-22 13:28
Yes, the markup (and therefore how the code is displayed in the docs) clearly indicates that the , between the lists is not part of the python syntax being discussed.
msg306779 - (view) Author: YCmove (YCmove) * Date: 2017-11-23 02:10
Yes, what Cheryl Sabella says is what I was misled to. 

Took me a while to understand that ``[a]``, ``[a, b, c]`` is not ``[a], [a, b, c]``, how about replace comma to "or" for more clarity? just like it used in [tuple documention](https://github.com/python/cpython/blob/master/Doc/library/stdtypes.rst#tuples)

Here is my rephrased version, and I add one more example of comma separated lists in tuple according to R. David Murray.
History
Date User Action Args
2022-04-11 14:58:54adminsetgithub: 76290
2017-11-23 02:10:39YCmovesethgrepos: + hgrepo374
messages: + msg306779
2017-11-22 13:28:59r.david.murraysetnosy: + r.david.murray
messages: + msg306727
2017-11-22 11:37:00berker.peksagsetmessages: + msg306724
2017-11-22 11:07:26cheryl.sabellasetnosy: + cheryl.sabella
messages: + msg306720
2017-11-22 07:09:18berker.peksagsetstatus: open -> closed

nosy: + berker.peksag
messages: + msg306698

resolution: not a bug
stage: patch review -> resolved
2017-11-22 06:54:39YCmovesetkeywords: + patch
stage: patch review
pull_requests: + pull_request4435
2017-11-22 06:46:32YCmovecreate