Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python tuple

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')
Source by codefreelance.net #
 
PREVIOUS NEXT
Tagged: #python #tuple
ADD COMMENT
Topic
Name
6+5 =