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


Groups > comp.lang.python > #7948

Re: NEED HELP-process words in a text file

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!selfless.tophat.at!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'example:': 0.03; '"""': 0.07; 'subject:process': 0.07; 'python': 0.08; 'argument,': 0.09; 'commonly': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'splitting': 0.09; 'output': 0.11; '>>>': 0.12; 'def': 0.12; 'subject:file': 0.14; 'computes': 0.16; 'docstrings': 0.16; 'encountered.': 0.16; 'filename,': 0.16; 'from:addr:behnel.de': 0.16; 'from:addr:stefan_ml': 0.16; 'from:name:stefan behnel': 0.16; 'lengths': 0.16; 'argument': 0.16; 'header:In-Reply-To:1': 0.21; 'code.': 0.22; '(or': 0.24; 'received:84': 0.25; 'stefan': 0.29; 'subject:HELP': 0.29; 'code,': 0.29; 'implement': 0.30; 'url:library': 0.31; 'print': 0.31; 'word.': 0.32; 'words,': 0.32; 'header:X-Complaints-To:1': 0.32; 'to:addr:python-list': 0.33; 'showing': 0.34; 'header:User-Agent:1': 0.35; 'executable': 0.35; 'numbers.': 0.35; 'subject:text': 0.36; 'beginning': 0.37; 'table': 0.37; 'url:docs': 0.37; 'two': 0.37; 'url:python': 0.38; 'received:org': 0.38; 'url:org': 0.38; 'subject:: ': 0.38; 'should': 0.39; 'header:Mime-Version:1': 0.39; 'to:addr:python.org': 0.39; '169': 0.91; 'james,': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Stefan Behnel <stefan_ml@behnel.de>
Subject Re: NEED HELP-process words in a text file
Date Sun, 19 Jun 2011 11:45:02 +0200
References <BANLkTinjLGSim79f1acOKzYgUq5xoSFdeg@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host dslb-084-056-009-240.pools.arcor-ip.net
User-Agent Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110424 Lightning/1.0b2 Thunderbird/3.1.10
In-Reply-To <BANLkTinjLGSim79f1acOKzYgUq5xoSFdeg@mail.gmail.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.142.1308476721.1164.python-list@python.org> (permalink)
Lines 44
NNTP-Posting-Host 82.94.164.166
X-Trace 1308476721 news.xs4all.nl 49039 [::ffff:82.94.164.166]:38798
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:7948

Show key headers only | View raw


Cathy James, 19.06.2011 01:21:
> def fileProcess(filename):
>      """Call the program with an argument,
>      it should treat the argument as a filename,
>      splitting it up into words, and computes the length of each word.
>      print a table showing the word count for each of the word lengths
> that has been encountered.
>      Example:
>      Length Count
>      1 16
>      2 267
>      3 267
>      4 169
>      >>>"&"
>      Length    Count
>      0    0
>      >>>
>      >>>"right."
>      Length    Count
>      5    10
>      """

Note that ">>>" is commonly used in docstrings to implement doctests. That 
is, it should represent the beginning of a line (or more) of executable 
Python code, followed by the expected output for that code.

Example:

     def add(x,y):
         """Add two numbers.

         >>> 1+1
         2
         >>> add(1,1)
         2
         >>> add(1,1) == 1+1
         True
         """
         return x+y

http://docs.python.org/library/doctest.html

Stefan

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


Thread

Re: NEED HELP-process words in a text file Stefan Behnel <stefan_ml@behnel.de> - 2011-06-19 11:45 +0200

csiph-web