Tuesday 15 September 2015

learn python the hard way exercise 20 -


I do not understand how the value of "variable_count" has been passed in this variable. If you can explain this to me, then I appreciate it !! Output prints each successive line. I understand how this line increases numbers (1, 2, 3, 4), but how exactly is it going to know where the data is being confusing me to print each string. import argv script from sys, input_file = argv def print_all (f): print f.read () def rewind (f): f.seek (0) def print_a_line (line_count, f) Print line_count, f.readline () current_file = open (input_file) Print "First come, print the whole file: \ n" print_al (current_file) Impressions "Now we rewind, like a tape." Print current_line (current_line, current_file) current_line = current_line + current_file) current_line = current_line + 1 print_a_line (current_line, current_file)

On f.readline () , each line will be read from f . After this, the file indicator of f will be at the beginning of the next line, therefore, the program constantly reads the lines.

No comments:

Post a Comment