nice python solution

Hung Jung Lu hungjunglu at yahoo.com
Thu Nov 22 12:51:30 EST 2001


"Magnus Lie Hetland" <mlh at idi.ntnu.no> wrote in message news:<9t9h3j$7r9$1 at tyfon.itea.ntnu.no>...
> Well... If you want an evil solution:
>   locals()[['a','b'][idx]] = val

I can think of:

(1) exec ('a=val', 'b=val')[idx]
(2) exec 'ab'[idx]+'=val'
(3) exec chr(97+idx)+'=val'

Hung Jung :)



More information about the Python-list mailing list