Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python typing namedtuple

>>> from collections import namedtuple
>>> Person = namedtuple('Person', 'first_name last_name zip_code')
>>> p1 = Person('Joe', 'Schmoe', '93002')
>>> p1.first_name
'Joe'
>>> p1[0]
'Joe'
>>> p1.zip_code
'92002'
>>> len(p1)
3
 
PREVIOUS NEXT
Tagged: #python #typing #namedtuple
ADD COMMENT
Topic
Name
2+8 =