Re: [Tutor] Initialize values from a text input file

2011-01-04 Thread Steven D'Aprano
Tim Johnson wrote: consider the following console session: L = ['foo','bar'] locals()[L[0]] = L[1] [...] (2) Even if it did work, do you trust the source of the text? Taking external data provided by arbitrary untrusted users and turning it into variables is a good way to have your compute

Re: [Tutor] Initialize values from a text input file

2011-01-03 Thread Tim Johnson
* Hugo Arts [110103 17:12]: > On Tue, Jan 4, 2011 at 2:06 AM, Alan Gauld wrote: > > > > "Tim Johnson" wrote > > > >>  Now, Alan, do you know anything about PHP? If you do, can you > >>  comment on the PHP extract() function? > > > > I know enough basic PHP to read a page with code in it and get

Re: [Tutor] Initialize values from a text input file

2011-01-03 Thread Hugo Arts
On Tue, Jan 4, 2011 at 2:06 AM, Alan Gauld wrote: > > "Tim Johnson" wrote > >>  Now, Alan, do you know anything about PHP? If you do, can you >>  comment on the PHP extract() function? > > I know enough basic PHP to read a page with code in it and get the general > drift. I've never written a lin

Re: [Tutor] Initialize values from a text input file

2011-01-03 Thread Alan Gauld
"Tim Johnson" wrote Now, Alan, do you know anything about PHP? If you do, can you comment on the PHP extract() function? I know enough basic PHP to read a page with code in it and get the general drift. I've never written a line of it and have learned enough about it that I don't want to

Re: [Tutor] Initialize values from a text input file

2011-01-03 Thread Tim Johnson
* Alan Gauld [110103 14:47]: > > "Tim Johnson" wrote > >> consider the following console session: > L = ['foo','bar'] > locals()[L[0]] = L[1] > foo >> 'bar' > locals() >> {'__builtins__': , 'L': ['foo', >> 'bar'], '__package__': None, '__name__': '__main__', 'foo': 'bar', >> '__do

Re: [Tutor] Initialize values from a text input file

2011-01-03 Thread Tim Johnson
* Steven D'Aprano [110103 15:03]: > Tim Johnson wrote: >> I'm just have a little fun here, but I bet that comments will help >> further elighten me on the subtleties of python. >> >> consider the following console session: > L = ['foo','bar'] > locals()[L[0]] = L[1] > > This will not do wh

Re: [Tutor] Initialize values from a text input file

2011-01-03 Thread Steven D'Aprano
Tim Johnson wrote: I'm just have a little fun here, but I bet that comments will help further elighten me on the subtleties of python. consider the following console session: L = ['foo','bar'] locals()[L[0]] = L[1] This will not do what you think it does. In general, local variables are not

Re: [Tutor] Initialize values from a text input file

2011-01-03 Thread Alan Gauld
"Tim Johnson" wrote consider the following console session: L = ['foo','bar'] locals()[L[0]] = L[1] foo 'bar' locals() {'__builtins__': , 'L': ['foo', 'bar'], '__package__': None, '__name__': '__main__', 'foo': 'bar', '__doc__': None} I could initialize variables in a local scope, or I co

[Tutor] Initialize values from a text input file

2011-01-03 Thread Tim Johnson
I'm just have a little fun here, but I bet that comments will help further elighten me on the subtleties of python. consider the following console session: >>> L = ['foo','bar'] >>> locals()[L[0]] = L[1] >>> foo 'bar' >>> 'foobar' in locals() False >>> 'foo' in locals() True >>> locals() {'__built