Created
February 13, 2016 11:21
-
-
Save fchevitarese/a43722eaec9e6f1621fc to your computer and use it in GitHub Desktop.
Cria objetos à partir de uma tupla com os dados do mesmo.
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 | |
Pessoa = namedtuple('Pessoa', 'nome idade flag') | |
pessoas = [('João', 32, False), ('Maria', 21, False), ('Paulo', 50, True)] | |
pessoas = (Pessoa(*p) for p in pessoas) | |
print(list(pessoas)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment