setting variables from a tuple NEWB
Marc 'BlackJack' Rintsch
bj_666 at gmx.net
Thu Jul 6 11:26:30 EDT 2006
In <jp9rg.17164$Uc3.15592 at tornado.texas.rr.com>, Paul McGuire wrote:
>>>> tupGlob = (('VOWELS','aeiou'),('CONS','bcdfgh'))
>>>> for nam,val in tupGlob: locals()[nam]=val
> ...
>>>> VOWELS
> 'aeiou'
>>>> CONS
> 'bcdfgh'
>>>>
Little warning: It works only on module level as assigning to `locals()`
return value in functions and methods has no effect on the "real" locals.
Ciao,
Marc 'BlackJack' Rintsch
More information about the Python-list
mailing list