namedtuple: Inherit unary/binary ops from tuple base class.
This commit is contained in:
@@ -5,8 +5,14 @@ T = namedtuple("Tup", "foo bar")
|
||||
#print(T)
|
||||
t = T(1, 2)
|
||||
print(t)
|
||||
print(t[0], t[1])
|
||||
print(t.foo, t.bar)
|
||||
|
||||
print(len(t))
|
||||
print(bool(t))
|
||||
print(t + t)
|
||||
print(t * 3)
|
||||
|
||||
print(isinstance(t, tuple))
|
||||
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user