Skip to content

Instantly share code, notes, and snippets.

@rikwatson
Created February 6, 2013 14:04
Show Gist options
  • Save rikwatson/4722688 to your computer and use it in GitHub Desktop.
Save rikwatson/4722688 to your computer and use it in GitHub Desktop.
Flatten Tuple
# python: how to flatten a tuple
#
# Basically the problem was that I wanted to create a flat tuple from a tuple and a single value like such:
#
val = 3
tup = ( 'a', 3.14, "zzz" )
# I wanted this:
#
# ( 3, 'a', 3.14, "zzz" )
#
# not this:
#
# ( 3, ( 'a', 3.14, "zzz" ) )
print (val,) + tup
# Easy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment