Skip to content

Instantly share code, notes, and snippets.

@doda-zz
Created July 23, 2012 18:05
Show Gist options
  • Save doda-zz/3165059 to your computer and use it in GitHub Desktop.
Save doda-zz/3165059 to your computer and use it in GitHub Desktop.
def eenum(l):
return dict((k,v) for l in (enumerate(l), ((x,i) for i,x in enumerate(l))) for k,v in l)
print eenum('asd')
>>> {0: 'a', 1: 's', 2: 'd', 'a': 0, 'd': 2, 's': 1}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment