globals () returns the dictionary of the current module, so you add elements to it, as in any other dictionary. Try:
for letter in ['a', ..., 'z']:
globals()[letter] = letter
or to eliminate the repeated call of global variables ():
global_dict = globals()
for letter in ['a', ..., 'z']:
global_dict[letter] = letter
or even:
globals().update((l,l) for l in ['a', ...,'z'])
source
share