Re: get a list from a string

2007-06-07 Thread Steven D'Aprano
Ah, sorry, pre-mature sending. Stupid keyboard accelerators :( To finish the sentence I was trying to write: On Thu, 07 Jun 2007 22:39:41 +1000, Steven D'Aprano wrote: > I wish even more that Python would come with a built-in "make a list from a > list representation" function, but that at least

Re: get a list from a string

2007-06-07 Thread Steven D'Aprano
On Thu, 07 Jun 2007 11:06:54 +, simon kagwe wrote: >> exec("distances = [[1,1,1,1],[2,2,2,2]]") > Wow! So simple! > > Thanks a lot. :-) Yes, and when you embed this in your web-application, using data gathered from a web-form, the black-hat hackers will thank you for the security hole too.

Re: get a list from a string

2007-06-07 Thread Josef Dalcolmo
simon kagwe wrote: > Hi, > > I have a string "distances = [[1,1,1,1],[2,2,2,2]]". I want to create a > variable called distances whose value is the list [[1,1,1,1],[2,2,2,2]]. How > can > I go about that? s = "distances = [[1,1,1,1],[2,2,2,2]]" exec(s) - Josef -- http://mail.python.org/mailm

Re: get a list from a string

2007-06-07 Thread Dustan
On Jun 7, 6:06 am, simon kagwe <[EMAIL PROTECTED]> wrote: > > exec("distances = [[1,1,1,1],[2,2,2,2]]") To be clear, exec is *not* a function; it's a statement. That means it can't be used in lambda functions, for example. > Wow! So simple! but dodgy, as it'll execute any python code. > Thanks

Re: get a list from a string

2007-06-07 Thread simon kagwe
> exec("distances = [[1,1,1,1],[2,2,2,2]]") Wow! So simple! Thanks a lot. :-) -- http://mail.python.org/mailman/listinfo/python-list

Re: get a list from a string

2007-06-07 Thread half . italian
On Jun 7, 3:34 am, simon kagwe <[EMAIL PROTECTED]> wrote: > Hi, > > I have a string "distances = [[1,1,1,1],[2,2,2,2]]". I want to create a > variable called distances whose value is the list [[1,1,1,1],[2,2,2,2]]. How > can > I go about that? I know I can use setattr, but how do I create the list

get a list from a string

2007-06-07 Thread simon kagwe
Hi, I have a string "distances = [[1,1,1,1],[2,2,2,2]]". I want to create a variable called distances whose value is the list [[1,1,1,1],[2,2,2,2]]. How can I go about that? I know I can use setattr, but how do I create the list from the string? Regards, Simon -- http://mail.python.org/mailman/