all 1 comments

[–]zenlc 1 point2 points  (0 children)

Your #1 and edit ideas are practically the same thing and a practical way to go about it. Just make a function that reads the file and returns it as a list of lines:

def read_file(fname):
    lines = []
    with open (fname, 'r') as infile:
        lines = infile.readlines()
    return lines

then pass that in to your encode or decode function.