* Alan Gauld <alan.ga...@btinternet.com> [110103 14:47]: > > "Tim Johnson" <t...@johnsons-web.com> wrote > >> consider the following console session: >>>>> L = ['foo','bar'] >>>>> locals()[L[0]] = L[1] >>>>> foo >> 'bar' >>>>> locals() >> {'__builtins__': <module '__builtin__' (built-in)>, 'L': ['foo', >> 'bar'], '__package__': None, '__name__': '__main__', 'foo': 'bar', >> '__doc__': None} >> >> I could initialize variables in a local scope, or I could build a >> dictionary. Actually the dictionary is preferable for the targeted >> application. Actually, the dictionary is the target medium
> Except in extreme cases I'd say a dictionary was better in almost any > situation. Messing with locals() is a dodgy business at best, and can > lead to debugging insanity at worst, its better to keep externally > initialized data explicit in almost every case. I agree, that's why I said I "was having a little fun". Now, Alan, do you know anything about PHP? If you do, can you comment on the PHP extract() function? thanks -- Tim tim at johnsons-web.com or akwebsoft.com http://www.akwebsoft.com _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor