Advertisement
here2share

# variable_generator.py

Jan 20th, 2016
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.20 KB | None | 0 0
  1. # variable_generator.py
  2.  
  3. def genVar(var_name,n):
  4.     _gv = globals()
  5.     for i in range(1, n+1):
  6.         _gv[var_name + '_' + str(i)] = i * 100
  7.  
  8. genVar('demo',3)
  9. print(demo_1)
  10. print(demo_2)
  11. print(demo_3)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement