Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python3 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: #tuple
ADD COMMENT
Topic
Name
4+4 =