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: Documented grammar for List displays incorrect (testlist)
Type: Stage:
Components: Documentation Versions: Python 2.4
process
Status: closed Resolution: later
Dependencies: Superseder:
Assigned To: jhylton Nosy List: georg.brandl, grubert, jhylton, kermode
Priority: normal Keywords:

Created on 2004-11-22 20:26 by kermode, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (4)
msg23248 - (view) Author: Lenard Lindstrom (kermode) Date: 2004-11-22 20:26
In section 5.2.4 of the Python Reference Manual for
Pythons 2.4 and 2.3 the definition

testlist ::= test ( "," test )* [ "," ]

should be

testlist ::= test [ ( "," test )+ [ "," ] ]

to conform with the definition of testlist_safe in the
Grammar definition file. In other words, a trailing
comma is not permitted if there is only one test in
testlist.
msg23249 - (view) Author: engelbert gruber (grubert) * Date: 2004-12-15 08:50
Logged In: YES 
user_id=147070

but

>>> testlist = 1,
>>> testlist
(1,)

so testlist = 1 does not produce a list

testlist ::= one "," ( another "," )* [and [","]]
msg23250 - (view) Author: Lenard Lindstrom (kermode) Date: 2004-12-17 00:00
Logged In: YES 
user_id=663274

Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more
information.
>>> [x for x in 1,]
  File "<stdin>", line 1
    [x for x in 1,]
                  ^
SyntaxError: invalid syntax
>>> [x for x in 1,2,]
[1, 2]
>>> for x in 1,:
...     print x
...
1
>>>
msg23251 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-07-30 11:02
Logged In: YES 
user_id=849994

This is subsumed by patch #1489771.
History
Date User Action Args
2022-04-11 14:56:08adminsetgithub: 41207
2004-11-22 20:26:09kermodecreate