[New-bugs-announce] [issue43180] Lists without commas?

Mike Siegel report at bugs.python.org
Tue Feb 9 11:02:17 EST 2021


New submission from Mike Siegel <mike.siegel at gmail.com>:

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.

----------
messages: 386725
nosy: mikesiegel
priority: normal
severity: normal
status: open
title: Lists without commas?

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43180>
_______________________________________


More information about the New-bugs-announce mailing list