Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from sys import argv # imports a module
- script, input_file = argv # you can give it the variable input_file a value when you run this script
- def print_all(f): # a function not sure what (f) means?
- print f.read() # reads the file
- def rewind(f): # not sure what this does , but it is a function
- f.seek(0) # not sure what seek means
- def print_a_line(line_count, f): # not sure what f stands for again
- print line_count, f.readline() # reads a file from the line
- current_file = open(input_file) # opens the input file and gives it the variable of current_file
- print "First lets print the whole file: \n"
- print_all(current_file) # I'm guessing the f earliar was a placeholder for the actual file now current_file
- print "Now lets reqind kind of like a tape." # simple print command
- rewind(current_file) # not sure what this function did see line 8
- print "Let's print three lines:" # simple print
- current_line = 1 # gives value of 1 to current line
- print_a_line(current_line, current_file) # calls function from line 11-12 & gives it variables
- current_line = current_line + 1 # same as above but the value of current line is + 1'd
- print_a_line(current_line, current_file)
- current_line = current_line + 1 # same as above
- print_a_line(current_line, current_file)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement