Created
November 29, 2023 06:01
-
-
Save rg3915/97e9afcb67f4de4a4e33995bbcc87976 to your computer and use it in GitHub Desktop.
namedtuple example
This file contains hidden or 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
from collections import namedtuple | |
data = ('Regis', 'Santos', '[email protected]') | |
first_name, last_name, email = data | |
print(first_name, last_name, email) | |
Person = namedtuple('Person', ['first_name', 'last_name', 'email']) | |
person = Person(*data) | |
print(person.first_name) | |
print(person.last_name) | |
print(person.email) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment