mirror of
https://github.com/micropython/micropython.git
synced 2026-01-07 12:40:15 +01:00
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:
committed by
Damien George
parent
2133924e46
commit
ca41dc2750
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user