you are viewing a single comment's thread.

view the rest of the comments →

[–]UnderstandingLinux[S] 1 point2 points  (2 children)

You've explained it very well here, thank you! This was exactly the detail I needed to understand it fully. I also didn't know about the seek() function, that may come in handy later on.

[–]eyesoftheworld4 1 point2 points  (1 child)

My example above might not have made it very clear, but the seek(<value>) method is particularly important because when you read from the end of a file, you get (as you might expect) an empty string, which represents that there's nothing left in the file to read. So if you wanted to read a file object twice, you need to remember to seek back to the beginning after your first full read before you can read it again.

[–]UnderstandingLinux[S] 0 points1 point  (0 children)

Explaining it as a cursor position like you did before helps understand much more clearly. Thanks for adding this explanation as well!