Skip to content

Instantly share code, notes, and snippets.

@pbexe
Created January 9, 2017 19:47
Show Gist options
  • Save pbexe/b8c2d551a69cd816c2d17e43afe01647 to your computer and use it in GitHub Desktop.
Save pbexe/b8c2d551a69cd816c2d17e43afe01647 to your computer and use it in GitHub Desktop.
Dynamically create variable names
_vars = 'these are some test variable names'.split(' ')
for index, var in enumerate(_vars):
s = var + ' = '+str(index)
exec(s)
print(these, are, some, test, variable, names)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment