Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!newsfeed.eweka.nl!feeder3.eweka.nl!81.171.88.15.MISMATCH!eweka.nl!lightspeed.eweka.nl!194.109.133.85.MISMATCH!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!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; '"""': 0.07; 'subject:string': 0.09; 'throw': 0.09; 'trailing': 0.09; 'skip:[ 20': 0.12; '"can\'t': 0.16; '-tkc': 0.16; 'delimited': 0.16; 'double,': 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; 'cc:addr:python-list': 0.16; 'wrote:': 0.18; 'cc:no real name:2**0': 0.20; 'subject:list': 0.21; 'header:In-Reply-To:1': 0.22; 'appear': 0.23; 'breaks': 0.23; 'cc:2**0': 0.24; 'skip:" 30': 0.28; 'cc:addr:python.org': 0.29; 'closing': 0.30; 'strings,': 0.30; 'whitespace': 0.30; 'header:User-Agent:1': 0.33; 'things': 0.34; 'subject:How': 0.35; 'used,': 0.38; 'should': 0.39; 'why': 0.39; 'raw': 0.40; 'might': 0.40; 'more': 0.61; 'leading': 0.62; 'touch': 0.70; 'row,': 0.84 Date: Wed, 30 Nov 2011 17:25:46 -0600 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: Hidura Subject: Re: How convert a list string to a real list References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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: 1322695556 news.xs4all.nl 6873 [2001:888:2000:d::a6]:38503 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:16464 On 11/30/11 16:48, Hidura wrote: > Why you don't make this "['1','2','3']".strip("[]").split(',') work for me because it breaks on things like s = """ [[1,2,3],42,'''triple the fun!''', "can't touch this, eh?",r'"Back\\\slashes?!", she said.', [4,5,6]] """ Commas can be embedded in strings, strings can be delimited with single, double, or triple quotes, raw strings can be used, more than one opening or closing "["/"]" can appear in a row, leading or trailing whitespace might throw you off...using ast.literal_eval() should just Do the Right Thing™. -tkc