Of course, I understand how to read and write text files in Python. However, I need to be able to read a file without Windows considering it "open" in another process. Here's the deal:
I have a Python script running on my Raspberry Pi that pulls a 3-digit number from a text document on my laptop over the network. I want to be able to change this text document whenever I wish and save it so the Python script updates almost immediately. Here's generally what I have right now.
while True:
text = open("/mnt/win/text.txt","r")
rgb = text.read()
text.close()
## ... Do stuff with rgb
time.sleep(.2)
This works out fine, because I essentially have a (slightly more than) .2 second loop in which the file "text.txt" is only open for a fairly small portion. However, whenever I modify "text.txt" through notepad, there is a chance that hitting save will give me an error saying the file is already open in another process. So that makes me wonder; is there a way around it? I have seen something similar in which the person used a PHP script to read the file and dumped that into their Python code, but I was kind of hoping to keep it all Python. Thanks!
EDIT: By the way, if it wasn't apparent, the folder that contains the text file on Windows was mounted to /mnt/win on Linux.