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


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

Re: NEED HELP-process words in a text file

Started byStefan Behnel <stefan_ml@behnel.de>
First post2011-06-19 11:45 +0200
Last post2011-06-19 11:45 +0200
Articles 1 — 1 participant

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

#7948 — Re: NEED HELP-process words in a text file

FromStefan Behnel <stefan_ml@behnel.de>
Date2011-06-19 11:45 +0200
SubjectRe: NEED HELP-process words in a text file
Message-ID<mailman.142.1308476721.1164.python-list@python.org>
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

[toc] | [standalone]


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


csiph-web