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


Groups > comp.lang.python > #94746 > unrolled thread

Re: String Attribute

Started byTerry Reedy <tjreedy@udel.edu>
First post2015-07-29 13:49 -0400
Last post2015-07-29 13:46 -0700
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: String Attribute Terry Reedy <tjreedy@udel.edu> - 2015-07-29 13:49 -0400
    Re: String Attribute John Strick <jstrickler@gmail.com> - 2015-07-29 13:46 -0700

#94746 — Re: String Attribute

FromTerry Reedy <tjreedy@udel.edu>
Date2015-07-29 13:49 -0400
SubjectRe: String Attribute
Message-ID<mailman.1076.1438192208.3674.python-list@python.org>
On 7/28/2015 7:38 PM, ltc.hotspot@gmail.com wrote:

> What is the source of the syntax error to the String Attribute?
>
> Go to the following URL links and view a copy of the raw data file code
> and sample data:
>
> 1.) http://tinyurl.com/p2xxxhl
> 2.) http://tinyurl.com/nclg6pq

If you want help here, reduce your code and input to the minimum needed, 
put the input in the code as a string, and if you still do not see the 
problem, post here, along with the traceback.

> Here is the desired output:
>
> stephen.marquard@uct.ac.za <mailto:stephen.marquard@uct.ac.za>
> louis@media.berkeley.edu <mailto:louis@media.berkeley.edu>

-- 
Terry Jan Reedy

[toc] | [next] | [standalone]


#94755

FromJohn Strick <jstrickler@gmail.com>
Date2015-07-29 13:46 -0700
Message-ID<b12afd12-3465-4671-9e54-52aa0c4a9425@googlegroups.com>
In reply to#94746
    fname = raw_input("Enter file name: ")
    if len(fname) < 1 : 
        fname = "mbox-short.txt"
    for line in fname:
        line = line.strip()
        if not line.startwith('From '): 
              continue
        line = line.split()
        count = count + 1


You need to actually open the file. (Look up how to do that) The first 'for' loop is looping through the file NAME, not the file OBJECT. Also, line.startwith() should be line.startswith().

--john

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web