Re: string to list of numbers conversion

2006-11-10 Thread Tim Williams
On 5 Nov 2006 04:34:32 -0800, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Hi, > I have a string '((1,2), (3,4))' and I want to convert this into a > python tuple of numbers. But I do not want to use eval() because I do > not want to execute any code in that string and limit it to list of > num

Re: string to list of numbers conversion

2006-11-08 Thread henning
[EMAIL PROTECTED] skrev: > Hi, > I have a string '((1,2), (3,4))' and I want to convert this into a > python tuple of numbers. I think your question is deeper and more natural than is clear from the many recepies given so far in this thread, so I'll take on another point of view, >From a langu

Re: string to list of numbers conversion

2006-11-06 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > I have a string '((1,2), (3,4))' and I want to convert this into a > python tuple of numbers. But I do not want to use eval() because I do > not want to execute any code in that string and limit it to list of > numbers. here's yet another approach: http://online.effb

Re: string to list of numbers conversion

2006-11-06 Thread Paul McGuire
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > I have a string '((1,2), (3,4))' and I want to convert this into a > python tuple of numbers. But I do not want to use eval() because I do > not want to execute any code in that string and limit it to list of

Re: string to list of numbers conversion

2006-11-06 Thread Frederic Rentsch
[EMAIL PROTECTED] wrote: > Hi, > I have a string '((1,2), (3,4))' and I want to convert this into a > python tuple of numbers. But I do not want to use eval() because I do > not want to execute any code in that string and limit it to list of > numbers. > Is there any alternative way? > > Thanks

Re: string to list of numbers conversion

2006-11-05 Thread Peter Otten
[EMAIL PROTECTED] wrote: > This recipe fails when negative numbers are used. > > safe_eval('(12, -12)') > *** Unsafe_Source_Error: Line 1. Unsupported source construct: > compiler.ast.UnarySub > > But, I think it could be easily fixed for somebody who understands the > script. I think that s

Re: string to list of numbers conversion

2006-11-05 Thread bearophileHUGS
[EMAIL PROTECTED] wrote: > Hi, > I have a string '((1,2), (3,4))' and I want to convert this into a > python tuple of numbers. But I do not want to use eval() because I do > not want to execute any code in that string and limit it to list of > numbers. > Is there any alternative way? This is

Re: string to list of numbers conversion

2006-11-05 Thread [EMAIL PROTECTED]
Peter, Thanks. This recipe fails when negative numbers are used. safe_eval('(12, -12)') *** Unsafe_Source_Error: Line 1. Unsupported source construct: compiler.ast.UnarySub But, I think it could be easily fixed for somebody who understands the script. Can somebody help. Thanks. Suresh Peter O

Re: string to list of numbers conversion

2006-11-05 Thread Peter Otten
[EMAIL PROTECTED] wrote: > I have a string '((1,2), (3,4))' and I want to convert this into a > python tuple of numbers. But I do not want to use eval() because I do > not want to execute any code in that string and limit it to list of > numbers. > Is there any alternative way? http://aspn.ac

Re: string to list of numbers conversion

2006-11-05 Thread Gerard Flanagan
[EMAIL PROTECTED] wrote: > Hi, > I have a string '((1,2), (3,4))' and I want to convert this into a > python tuple of numbers. But I do not want to use eval() because I do > not want to execute any code in that string and limit it to list of > numbers. > Is there any alternative way? Python

string to list of numbers conversion

2006-11-05 Thread [EMAIL PROTECTED]
Hi, I have a string '((1,2), (3,4))' and I want to convert this into a python tuple of numbers. But I do not want to use eval() because I do not want to execute any code in that string and limit it to list of numbers. Is there any alternative way? Thanks. Suresh -- http://mail.python.org/mai