Named Tuples for Readable Code in Python


Create tuples with named fields.

Source Code

from collections import namedtuple
Point = namedtuple("Point", ["x", "y"])
p = Point(10, 20)
print(p.x, p.y)
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments