what are some methods for open()?
i want to know when the end of file is incountered like so:

def saveFile(filename):
    fout = open(filename 'w')
    while not fout.EOF():
        fout.write(havnt figured out what to do here but dw bout it)

any ideas?

Recommended Answers

All 2 Replies

This might be the easiest thing to do:

fh = open('myfile.txt')
for each_line in fh:
    print each_line.strip().replace(':', '|')
fh.close()

That'll iterate line by line through the file and print out each line only replacing all occurences of ':' with '|'...

You could alternately use methods read(), readline(), or readlines()... here's some documentation on the file object.

Hope that helps.

thanks. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.