Last active
June 13, 2019 16:32
-
-
Save filipwodnicki/a9674638fd8c3bc5f4c00a8a800bc3e6 to your computer and use it in GitHub Desktop.
How to use Named Tuples in Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# source: https://pymotw.com/2/collections/namedtuple.html | |
# doc: https://docs.python.org/3.7/library/collections.html#collections.namedtuple | |
import collections | |
Person = collections.namedtuple('Person', field_names=['name', 'age', 'gender']) | |
filip = Person(name='Filip', age=101, gender='undisclosed') | |
print(filip.name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment