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


Groups > comp.lang.python > #79863

Re: Anyone know the solution

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <cameron@cskk.homeip.net>
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; 'function,': 0.09; 'line:': 0.09; 'performs': 0.09; 'statements': 0.09; 'subject:Anyone': 0.09; 'anyway': 0.14; 'dictionary.': 0.16; 'file1': 0.16; 'fits': 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'intended.': 0.16; 'line.split()': 0.16; 'message-id:@cskk.homeip.net': 0.16; 'received:211.29': 0.16; 'received:211.29.132': 0.16; 'received:cskk.homeip.net': 0.16; 'received:homeip.net': 0.16; 'received:optusnet.com.au': 0.16; 'received:syd.optusnet.com.au': 0.16; 'simpson': 0.16; 'skip:> 20': 0.16; 'wrote:': 0.18; 'fit': 0.20; 'seems': 0.21; 'print': 0.22; 'this?': 0.23; 'header:User- Agent:1': 0.23; 'cheers,': 0.24; 'looks': 0.24; 'question': 0.24; 'header:In-Reply-To:1': 0.27; 'rest': 0.29; 'code': 0.31; 'file': 0.32; 'probably': 0.32; 'subject:the': 0.34; 'but': 0.35; 'received:com.au': 0.36; 'skip:> 10': 0.36; 'charset:us-ascii': 0.36; 'should': 0.36; 'list.': 0.37; 'received:211': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'read': 0.60; 'content-disposition:inline': 0.62; 'sample': 0.67; 'legal': 0.71; 'accompany': 0.84; 'bare': 0.84; 'subject:know': 0.84
Date Wed, 29 Oct 2014 11:53:46 +1100
From Cameron Simpson <cs@zip.com.au>
To python-list@python.org
Subject Re: Anyone know the solution
MIME-Version 1.0
Content-Type text/plain; charset=us-ascii; format=flowed
Content-Disposition inline
In-Reply-To <f9c39375-d0ff-4f16-aa05-6d8c8fdf7267@googlegroups.com>
User-Agent Mutt/1.5.21 (2010-09-15)
References <f9c39375-d0ff-4f16-aa05-6d8c8fdf7267@googlegroups.com>
X-Optus-CM-Score 0
X-Optus-CM-Analysis v=2.1 cv=fvDlOjIf c=1 sm=1 tr=0 a=YuQlxtEQCowy2cfE5kc7TA==:117 a=YuQlxtEQCowy2cfE5kc7TA==:17 a=ZtCCktOnAAAA:8 a=PO7r1zJSAAAA:8 a=LcaDllckn3IA:10 a=r5UFkecV8NkA:10 a=kj9zAlcOel0A:10 a=vrnE16BAAAAA:8 a=pGLkceISAAAA:8 a=uGQ_b2ZQJEks2-rZxb8A:9 a=CjuIK1q_8ugA:10
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.15274.1414544041.18130.python-list@python.org> (permalink)
Lines 47
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1414544041 news.xs4all.nl 2883 [2001:888:2000:d::a6]:51119
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:79863

Show key headers only | View raw


On 28Oct2014 09:07, ngangsia akumbo <ngangsia@gmail.com> wrote:
>This is a sample code on how to read data from a file
>
>files1 {}
>
>result = open("file1.txt")
>for line in result:
>    file1 = line>split()
>files1.append(file1)
>result.close()
>file1.sort()
>file1.reverse()
>
>print('THE FILE INFO')
>
>print(file1(0)
>print(file1(1)

Do you have a specific question to accompany this?

The code above is syntactly invalid, so it will not run.

The line:

   files1 {}

is invalid, but looks like it is intended to initialise files1 as a dictionary.  
However, the rest of the program seems to use it as though it were a list.

The line:

   file1 = line>split()

should probably be written:

   file1 = line.split()

With ">" it is legal (as it performs a comparison) but will fail because 
there's no bare "split()" function, and anyway is probably not as intended.

Your final print statements need an extra closing parenthesis each.

Cheers,
Cameron Simpson <cs@zip.com.au>

I fit in my suit, my suit fits in my suitcase, hence i fit in my suitcase.
         - Cees Keyer <cees@htsa.hva.nl>

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


Thread

Anyone know the solution emmanueloje@gmail.com - 2014-10-27 08:10 -0700
  Re: Anyone know the solution alister <alister.nospam.ware@ntlworld.com> - 2014-10-27 15:21 +0000
  Re: Anyone know the solution Joel Goldstick <joel.goldstick@gmail.com> - 2014-10-27 11:20 -0400
  Re: Anyone know the solution Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-10-27 20:18 -0400
  Re: Anyone know the solution Denis McMahon <denismfmcmahon@gmail.com> - 2014-10-28 00:20 +0000
  Re: Anyone know the solution alex23 <wuwei23@gmail.com> - 2014-10-28 10:33 +1000
    Re: Anyone know the solution Anton <anton.schattenfeld@gmail.com> - 2014-10-28 18:28 -0700
      Re: Anyone know the solution alex23 <wuwei23@gmail.com> - 2014-10-29 12:03 +1000
      Re: Anyone know the solution Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-10-29 18:13 +1300
        Re: Anyone know the solution Anton <anton.schattenfeld@gmail.com> - 2014-10-29 17:09 -0700
  Re: Anyone know the solution Terry Reedy <tjreedy@udel.edu> - 2014-10-28 00:24 -0400
    Re: Anyone know the solution "Mario R. Osorio" <nimbiotics@gmail.com> - 2014-10-28 08:38 -0700
  Re: Anyone know the solution ngangsia akumbo <ngangsia@gmail.com> - 2014-10-28 09:07 -0700
    Re: Anyone know the solution Cameron Simpson <cs@zip.com.au> - 2014-10-29 11:53 +1100
    Re: Anyone know the solution Dave Angel <davea@davea.name> - 2014-10-28 22:11 -0400
  Re: Anyone know the solution Denis McMahon <denismfmcmahon@gmail.com> - 2014-10-29 18:03 +0000

csiph-web