Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news-transit.tcx.org.uk!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!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.008 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'received:verizon.net': 0.07; 'header:In-reply-to:1': 0.09; 'received:206.46': 0.09; 'received:206.46.173': 0.09; 'subject:string': 0.09; 'carefully.': 0.16; 'cc:addr:python-list': 0.16; 'wrote:': 0.18; '>>>': 0.18; 'cc:no real name:2**0': 0.20; 'subject:list': 0.21; 'cc:2**0': 0.24; 'skip:" 30': 0.28; 'lists': 0.28; 'cc:addr:python.org': 0.29; 'pm,': 0.29; 'received:192.168.1.3': 0.30; 'list': 0.32; 'header:User-Agent:1': 0.33; 'anything': 0.34; 'subject:How': 0.35; 'received:192': 0.37; 'why': 0.39; 'received:192.168': 0.40; 'more': 0.61; "'2',": 0.84 Date: Wed, 30 Nov 2011 18:12:14 -0500 From: Terry Reedy User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20111105 Thunderbird/8.0 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: 7bit 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: 14 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1322694757 news.xs4all.nl 6942 [2001:888:2000:d::a6]:38065 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:16462 On 11/30/2011 5:48 PM, Hidura wrote: > Why you don't make this "['1','2','3']".strip("[]").split(',') work for me Look more carefully. This is not the same as ast.literal_eval(). >>> "['1','2','3']".strip("[]").split(',') ["'1'", "'2'", "'3'"] # list of 3-char strings >>> ast.literal_eval("['1','2','3']") ['1', '2', '3'] # list of 1-char strings Even if it were the same, it would be specific to lists of strings and would not work for anything else.