Python: write to file multiple times without open/close for each write
file, python
Solution
You can just keep the file object around and write to it whenever you want. You might need to `flush` it after each write to make things visible to the outside world.
If you do the writes from a different process, just open the file in append mode ("a").
Problem
How can i open file in python and write to it multiple times? I am using speech recognition, and i want one file to change its contents based on what i say. Other application needs to be able to read this file. Is there way to do this, or i need to open/close for each write?