Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python named typle

from collections import namedtuple

Point = namedtuple('Point', 'x y')
p = Point(1, y=2)

p[0]
# 1
p.x
# 1
getattr(p, 'y')
# 2
p._fields  # Or: Point._fields
# ('x', 'y')
 
PREVIOUS NEXT
Tagged: #python #named #typle
ADD COMMENT
Topic
Name
2+9 =