Skip to content

Instantly share code, notes, and snippets.

@arisada
Created February 2, 2016 10:32
Show Gist options
  • Save arisada/921f786d384b1e79873d to your computer and use it in GitHub Desktop.
Save arisada/921f786d384b1e79873d to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
from collections import namedtuple
def maketuple(name, params, data):
tclass=namedtuple(name, params)
d = tclass._make(data[i] for i in params.split(' '))
return d
data = {
"a2":2, "a1":1, "a3":3
}
print (maketuple("test", "a1 a2 a3", data))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment