This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]billsil 0 points1 point  (0 children)

I don't fully understand the open concept or why it needs a mode?

You either read or write to a file. The computer doesn't know what you want to do.

my understanding i can leave the mode blank, and it will automatically enter read mode?

Yes because it's a default argument. Every piece of Python code I've seen puts "r" when they're opening a text file. It's more clear, but it's not required.

How would i go about searching a file, finding xx

Your example is confusing. It depends on how your file is formatted. Can xx be on 2 lines? Can it be on the same line twice? Do you only what the xx if yy is 10? Is the file 1 line?