blob: 0caf93a117447d5f39d0a8dbe38d11f1f4b9d94e [file] [log] [blame]
Tor Norbye3a2425a2013-11-04 10:16:08 -08001from collections import namedtuple
2
3Point = namedtuple('Point', ['x', 'y'], verbose=True)
4
5print(Point.x, Point.y)
6
7p = Point(11, y=22)
8print(p.x + p.y + p.<warning descr="Unresolved attribute reference 'z' for class 'Point'">z</warning>)
9print(p.__add__)
10print(p._asdict())
11print(Point._fields)
12print(p._replace)
13
14if isinstance(p, Point):
15 p.x
16
17class C(namedtuple('C', 'x y')):
18 def f(self):
19 return self
20
21c = C()
22print(c.x, c.y, c.<warning descr="Unresolved attribute reference 'z' for class 'C'">z</warning>, c.f())