Skip to content

Instantly share code, notes, and snippets.

@fchevitarese
Created February 13, 2016 11:21
Show Gist options
  • Save fchevitarese/a43722eaec9e6f1621fc to your computer and use it in GitHub Desktop.
Save fchevitarese/a43722eaec9e6f1621fc to your computer and use it in GitHub Desktop.
Cria objetos à partir de uma tupla com os dados do mesmo.
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