Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #56271

Re: how to read list from file

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 <ganeshsahni07@gmail.com>
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 <fbc6e512-88fa-4de0-80d3-6757fcc52af4@googlegroups.com> <mailman.767.1381022585.18130.python-list@python.org> <61d4be5e-5483-4e1c-9b85-8dac7d6d5ea2@googlegroups.com>
From Ravi Sahni <ganeshsahni07@gmail.com>
Date Sun, 6 Oct 2013 22:20:01 +0530
Subject Re: how to read list from file
To Harvey Greenberg <hjgreenberg@gmail.com>
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 <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.788.1381078230.18130.python-list@python.org> (permalink)
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

Show key headers only | View raw


On Sun, Oct 6, 2013 at 10:11 PM, Harvey Greenberg <hjgreenberg@gmail.com> 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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

how to read list from file Harvey Greenberg <hjgreenberg@gmail.com> - 2013-10-05 18:08 -0700
  Re: how to read list from file Tim Chase <python.list@tim.thechases.com> - 2013-10-05 20:24 -0500
    Re: how to read list from file Roy Smith <roy@panix.com> - 2013-10-05 21:35 -0400
    Re: how to read list from file Harvey Greenberg <hjgreenberg@gmail.com> - 2013-10-06 09:41 -0700
      Re: how to read list from file Harvey Greenberg <hjgreenberg@gmail.com> - 2013-10-06 09:46 -0700
      Re: how to read list from file Ravi Sahni <ganeshsahni07@gmail.com> - 2013-10-06 22:20 +0530
      Re: how to read list from file Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2013-10-07 09:04 +0300
  Re: how to read list from file Roy Smith <roy@panix.com> - 2013-10-05 21:34 -0400
  Re: how to read list from file Terry Reedy <tjreedy@udel.edu> - 2013-10-06 02:24 -0400
  Re: how to read list from file Harvey Greenberg <hjgreenberg@gmail.com> - 2013-10-06 09:57 -0700
    Re: how to read list from file Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-06 18:24 +0100
    Re: how to read list from file Ravi Sahni <ganeshsahni07@gmail.com> - 2013-10-06 23:08 +0530

csiph-web