Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

named tuple python iterate

>>> a = A(1, 2)
>>> for name, value in a._asdict().iteritems():
    print name
    print value


a
1
b
2

>>> for fld in a._fields:
    print fld
    print getattr(a, fld)


a
1
b
2
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #named #tuple #python #iterate
ADD COMMENT
Topic
Name
3+9 =