Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

tuple in python

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 #python
ADD COMMENT
Topic
Name
8+5 =