Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3.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.015 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'subject:file': 0.07; '[1,': 0.09; 'input,': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'jan': 0.12; '-tkc': 0.16; '2.7.3': 0.16; '3],': 0.16; 'ast': 0.16; 'ravi': 0.16; 'repr': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'import': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'skip:l 30': 0.24; 'looks': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'tim': 0.29; 'subject:list': 0.30; 'message-id:@mail.gmail.com': 0.30; 'work.': 0.31; 'gives': 0.31; 'chase': 0.31; 'subject:from': 0.34; 'but': 0.35; 'received:google.com': 0.35; "didn't": 0.36; 'should': 0.36; 'list': 0.37; 'thank': 0.38; 'pm,': 0.38; 'remove': 0.60; 'more': 0.64; 'to:addr:gmail.com': 0.65; '10:11': 0.84; 'again?': 0.84; 'subject:read': 0.84; '2013,': 0.91; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=Gr13zYFjUJTF80YuMswGbRmOTbHV+pItUffY5no/nkI=; b=ucFfLih3SFG+UD48eFER/oWfubXII+BINw9Fpm4tIkekdWUyRYFvSEl/Ji8bAqlGw2 4KigF4Rkc74zew1A6WNhvQaAJlQrBVDDl7+OX28ZIFMswOVlYSgoFCo9VP0yEildfuib 67tBD3ra8XInGudsuGjDrzAJGxhTX7SaZs2BN+GhXD8tDlW1Z8fPN33gYWf/VfinDxvt Es6ntzHvXRAKAlbdEKuZXlnYyjIqPvXo7a1fo1SS5dMqLgIL2z9SqwVrPsgTKRWLPBJC EjYGupNuQDp4+LqRkNjXfDfz7gh5VGL9y6JgA2TqBnOmcJZ7CVOc4+giWa2JVXR6hhLd sYEw== X-Received: by 10.68.190.103 with SMTP id gp7mr26260308pbc.74.1381078221838; Sun, 06 Oct 2013 09:50:21 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <61d4be5e-5483-4e1c-9b85-8dac7d6d5ea2@googlegroups.com> References: <61d4be5e-5483-4e1c-9b85-8dac7d6d5ea2@googlegroups.com> From: Ravi Sahni Date: Sun, 6 Oct 2013 22:20:01 +0530 Subject: Re: how to read list from file To: Harvey Greenberg Content-Type: text/plain; charset=ISO-8859-1 Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 22 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1381078230 news.xs4all.nl 15911 [2001:888:2000:d::a6]:56538 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:56271 On Sun, Oct 6, 2013 at 10:11 PM, Harvey Greenberg wrote: > On Saturday, October 5, 2013 7:24:39 PM UTC-6, Tim Chase wrote: >> Python 2.7.3 (default, Jan 2 2013, 13:56:14) >> [GCC 4.7.2] on linux2 >> Type "help", "copyright", "credits" or "license" for more >> information. >> >>> s = "[{'a':1, 'b':2}, [1,2,3], 10]" >> >>> import ast >> >>> print repr(ast.literal_eval(s)) >> [{'a': 1, 'b': 2}, [1, 2, 3], 10] >> >> >> >> -tkc > > that didn't work. printing it looks like the list because it's the input, but try printing len(repr(ast.literal_eval(s))). It should give 3, but it gives 72 (number of chars). Please to remove the repr and try again? Thank you! -- Ravi