Skip to content

Commit

Permalink
With Python3 refactoring code
Browse files Browse the repository at this point in the history
Now Python 3 is the mainstream.
  • Loading branch information
ttzc authored Jan 29, 2020
1 parent 7fb2c5e commit 89f44a2
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions ex20.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@


def print_all(f):
print
f.read()
print(f.read())


# seek(n) to read a file's content from byte-n
Expand All @@ -14,22 +13,18 @@ def rewind(f):


def print_a_line(line_count, f):
print
line_count, f.readline()
print(line_count, f.readline())


current_file = open(input_file)

print
"First let's print the whole file:\n"
print("First let's print the whole file:\n")
print_all(current_file)

print
"Now let's rewind, kind of like a tape."
print("Now let's rewind, kind of like a tape.")
rewind(current_file)

print
"Let's print three lines:"
print("Let's print three lines:")
current_line = 1
print_a_line(current_line, current_file)

Expand Down

0 comments on commit 89f44a2

Please sign in to comment.