Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Re: help (http://www.velocityreviews.com/forums/t948286-re-help.html)

Tim Chase 07-19-2012 11:14 PM

Re: help
 
On 07/19/12 17:31, Miriam Gomez Rios wrote:
> Hello, sorry for bothering you, but I have a doubt,
>
> Is there a way to turn this string into a tuplelist??????, I
> need it for gurobi
>
> ('per1','persona1.1','pro1'),('per1','persona1.1', 'pro2'),('per1','persona1.1','pro3'),...,('per2',' persona2.4','pro3'


Assuming a closing paren, you can safely use ast.literal_eval on the
raw string:

import ast
s = "('per1','persona1.1','pro1'),('per1','persona1.1' ,'pro2')"
resulting_tuple_of_tuples = ast.literal_eval(s)

-tkc





All times are GMT. The time now is 07:28 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.