py/objnamedtuple: Allow passing field names as a tuple.

So the documentation's example works.  Besides, a tuple can be more
memory efficient.
This commit is contained in:
Antonin ENFRUN
2016-05-22 19:28:04 +02:00
committed by Damien George
parent 2133924e46
commit ca41dc2750
2 changed files with 6 additions and 4 deletions

View File

@@ -66,6 +66,11 @@ T3 = namedtuple("TupComma", "foo bar")
t = T3(1, 2)
print(t.foo, t.bar)
# Try tuple
T4 = namedtuple("TupTuple", ("foo", "bar"))
t = T4(1, 2)
print(t.foo, t.bar)
# Try single string with comma field seperator
# Not implemented so far
#T2 = namedtuple("TupComma", "foo,bar")