Is there a simple way to parse this string ?

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Sat Dec 22 20:37:01 EST 2007


On Sat, 22 Dec 2007 07:21:26 -0800, josepharmbruster at gmail.com wrote:

> Steven D'Aprano,
> 
> On Dec 21, 2:08 am, Steven D'Aprano
> <ste... at REMOVE.THIS.cybersource.com.au> wrote:
>> On Thu, 20 Dec 2007 20:27:23 -0800, josepharmbrus... at gmail.com wrote:
>> > Stef,
>>
>> > For clarification, there is nothing hazardous about using eval on the
>> > string that you presented.
>>
>> > t = eval('(0, 0, 0, 255), (192, 192, 192, 255), True, 8')
>>
>> > Whether or not this is the "simplest" solution, remains a question.
>>
>> For clarification, if all the poster wanted was to convert the
>> *specific* *known* string to a tuple, he would be better off just
>> writing it as a tuple:
> 
> Steven,
> 
> No, that's not what he asked.  Read the original question.

I did. I even read all the way down to the part where he wrote:

"(Not needed now, but might need it in the future: even deeper nested 
lists, represented by a string.)"

Its clear that the OP has more in mind than just a single specific known 
string.



-- 
Steven



More information about the Python-list mailing list