diff options
author | Medini Kadam | 2011-05-04 14:53:52 +0530 |
---|---|---|
committer | Medini Kadam | 2011-05-04 14:53:52 +0530 |
commit | 3cb764ddfee1b297561f4614e83db72b223210e9 (patch) | |
tree | 256edf6ff11dd126f8250704a84d073fc5bd9a03 /getting_started_with_files/script.rst | |
parent | 8f769af90d747f7e12e4ef64ec2ee9dabf19b727 (diff) | |
download | st-scripts-3cb764ddfee1b297561f4614e83db72b223210e9.tar.gz st-scripts-3cb764ddfee1b297561f4614e83db72b223210e9.tar.bz2 st-scripts-3cb764ddfee1b297561f4614e83db72b223210e9.zip |
Revised the script - 'Getting started with files'.
Diffstat (limited to 'getting_started_with_files/script.rst')
-rw-r--r-- | getting_started_with_files/script.rst | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/getting_started_with_files/script.rst b/getting_started_with_files/script.rst index bd3dc9b..259be80 100644 --- a/getting_started_with_files/script.rst +++ b/getting_started_with_files/script.rst @@ -1,11 +1,11 @@ .. Objectives .. ---------- -.. By the end of this tutorial, you will be able to -.. 1. Open and read the contents of a file. -.. #. Read files line by line. -.. #. Read all the contents of the file at once. -.. #. Close open files. +.. At the end of this spoken tutorial, you will be able to: +.. 1. Open a file. +.. #. Read the content of the file line by line. +.. #. Read entire contents of the file at once. +.. #. Close the file. .. Prerequisites .. ------------- @@ -58,8 +58,7 @@ or write) in which it is open. Notice that it is open in read only mode, here. We shall first learn to read the whole file into a single -variable. Later, we shall look at reading it line-by-line. We use -the ``read`` method of ``f`` to read, all the contents of the file +variable. We use the ``read`` method of ``f`` to read, all the contents of the file into the variable ``pend``. :: @@ -134,7 +133,7 @@ the file line-wise and print each of the lines. for line in f: print line -As we already know, ``line`` is variable, sometimes called the loop +``line`` is variable, sometimes called the loop variable, and it is not a keyword. We could have used any other variable name, but ``line`` seems meaningful enough. |