Skip to content

Instantly share code, notes, and snippets.

@asher-pembroke
Last active September 26, 2017 15:03
Show Gist options
  • Select an option

  • Save asher-pembroke/01a8dc2844f6a7738ebddf2da18f18fc to your computer and use it in GitHub Desktop.

Select an option

Save asher-pembroke/01a8dc2844f6a7738ebddf2da18f18fc to your computer and use it in GitHub Desktop.
Merge two named tuples in python
def merge_tuples(a,b, name = 'Name'):
"""Returns a join of two named tuples
Duplicate names will raise an error.
"""
return namedtuple(name, a._fields + b._fields)(*(a+b))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment