# HG changeset patch # User Puneeth Chaganti # Date 1288972030 -19800 # Node ID 4b3c0d8fffe2f8fe59c7dd7ba6e341726dcc4702 # Parent fa4c9b11452b04deac9211cb0f12103c0d0ed232 Changes to getting started with files based on review. diff -r fa4c9b11452b -r 4b3c0d8fffe2 getting-started-files/script.rst --- a/getting-started-files/script.rst Fri Nov 05 21:01:23 2010 +0530 +++ b/getting-started-files/script.rst Fri Nov 05 21:17:10 2010 +0530 @@ -77,7 +77,7 @@ Following is an exercise that you must do. -.. #[[Anoop:add context switch to next slide - questions]] +{{ show slide with Question 1 }} %%1%% Split the variable into a list, ``pend_list``, of the lines in the file. Hint, use the tab command to see what methods the string @@ -85,14 +85,7 @@ Please, pause the video here. Do the exercise and then continue. -.. #[punch: should this even be put? add dependency to strings LO, -.. where we mention that strings have methods for manipulation. hint: -.. use splitlines()] - -.. #[[Anoop: let us have it here, let us consider this as a - refresher]] - -.. #[[Anoop:add context switch to next slide - solution]] +{{ show slide with Solution 1 }} :: @@ -104,12 +97,6 @@ will have to close the file, since the file has already been read till the end. -.. #[punch: should we mention file-pointer?] - -.. #[[Anoop: I think we can say that ``f`` is a file pointer which - points to the next line/data to be read from the file. We could - skip details.]] - Let us close the file opened into f. :: @@ -146,12 +133,9 @@ for line in f: print line -As we already know, ``line`` is just a dummy variable, and not a -keyword. We could have used any other variable name, but ``line`` -seems meaningful enough. - -.. #[[Anoop: using dummy variable doesn't seem correct, can say line - is a variable]] +As we already know, ``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. Instead of just printing the lines, let us append them to a list, ``line_list``. We first initialize an empty list, ``line_list``. @@ -181,15 +165,12 @@ contain the newline characters, because the string ``pend`` was split on the newline characters. -.. #[[Anoop: I think we need to tell them that each line can be - stripped and appended to list to avoid the problem of newline - characters.]] +Using some string methods, that we shall look at in the tutorial on +strings, we can strip out the newline characters from the lines. .. #[[Anoop: I think the code that are required to be typed can be added to the slide.]] -.. #[[Anoop: Context switches are to be added.]] - {{{ show the summary slide }}} That brings us to the end of this tutorial. In this tutorial we