Consider the presence of the test.txt file with some random text in it.
Now we run the following code:
f = open('test.txt', 'r') f.read()
Now we are adding data to test.txt from some other process. Is there some way without reopening f that we can read new data?
This question is limited to Python; it is just a short code to get the point.
Edit: I tried everything I know (redness, reading, searching, etc.), but this does not update anything.
Edit: since it seems that the behavior is different depending on how the file is “added to”, I will give a more specific setting. I'm on OS X 10.9, and I'm trying to read /var/log/system.log , which syslogd is written in.
Edit: Looks like I was wrong. Using read will produce new data, but if the data is small, then you must first use flush to read it.
source share