Add comments to NamedTuple code.
Let the field spec be either a string or a non-string sequence (suggested by Martin Blais with use cases).
Improve the error message in the case of a SyntaxError (caused by a duplicate field name).
diff --git a/Lib/test/test_collections.py b/Lib/test/test_collections.py
index 939c3ce..c260bc7 100644
--- a/Lib/test/test_collections.py
+++ b/Lib/test/test_collections.py
@@ -40,6 +40,11 @@
p = Point(x=11, y=22)
self.assertEqual(repr(p), 'Point(x=11, y=22)')
+ # verify that fieldspec can be a non-string sequence
+ Point = NamedTuple('Point', ('x', 'y'))
+ p = Point(x=11, y=22)
+ self.assertEqual(repr(p), 'Point(x=11, y=22)')
+
def test_tupleness(self):
Point = NamedTuple('Point', 'x y')
p = Point(11, 22)