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: Lists without commas?
Type: Stage: resolved
Components: Versions:
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: mark.dickinson, mikesiegel
Priority: normal Keywords:

Created on 2021-02-09 16:02 by mikesiegel, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg386725 - (view) Author: Mike Siegel (mikesiegel) Date: 2021-02-09 16:02
Perhaps I'm missing something here but this behavior seems unexpected to me. "Lists

    The items of a list are arbitrary Python objects. Lists are formed by placing a *comma-separated* list of expressions in square brackets. (Note that there are no special cases needed to form lists of length 0 or 1.)"

>>> import sys
>>> print(sys.version)
3.7.3 (default, Jul 25 2020, 13:03:44)
[GCC 8.3.0]
>>> test = [ "foo" "bar" ]
>>> type(test)
<class 'list'>
>>> print(test)
['foobar']
>>> import json
>>> json.dumps({ "foo": test })
'{"foo": ["foobar"]}'
>>>

In a complex dict structure this is an easy way to shoot yourself in the foot.
msg386726 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2021-02-09 16:06
This is by design. It's not really to do with lists, but to do with  placing two string literals next to each other.

See: https://docs.python.org/3/reference/lexical_analysis.html#string-literal-concatenation

See also https://www.python.org/dev/peps/pep-3126/ .

I'll close here.
History
Date User Action Args
2022-04-11 14:59:41adminsetgithub: 87346
2021-02-09 16:06:59mark.dickinsonsetstatus: open -> closed

nosy: + mark.dickinson
messages: + msg386726

resolution: not a bug
stage: resolved
2021-02-09 16:02:17mikesiegelcreate