Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!xlned.com!feeder7.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:help': 0.07; 'ast': 0.09; 'gomez': 0.09; 'cc:addr:python-list': 0.10; '-tkc': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'message-id:@tim.thechases.com': 0.16; 'received:70.251': 0.16; 'received:dsl.rcsntx.swbell.net': 0.16; 'received:rcsntx.swbell.net': 0.16; 'received:swbell.net': 0.16; 'string:': 0.16; 'string': 0.17; 'wrote:': 0.17; 'import': 0.21; 'assuming': 0.22; 'cc:2**0': 0.23; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'raw': 0.27; 'skip:" 50': 0.27; 'safely': 0.33; 'there': 0.35; 'but': 0.36; 'closing': 0.36; 'turn': 0.36; 'subject:: ': 0.38; 'hello,': 0.39; 'received:50.22': 0.84 Date: Thu, 19 Jul 2012 18:14:33 -0500 From: Tim Chase User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111120 Icedove/3.1.16 MIME-Version: 1.0 To: Miriam Gomez Rios Subject: Re: help References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - boston.accountservergroup.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tim.thechases.com X-Source: X-Source-Args: X-Source-Dir: Cc: "python-list@python.org" X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 19 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1342739610 news.xs4all.nl 6860 [2001:888:2000:d::a6]:38908 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:25658 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