Change a file type in Python?

Eamonn Rea eamonnrea at gmail.com
Sat Nov 30 17:45:18 EST 2013


When opening a file, you'd say whether you want to read or write to a file. This is fine, but say for example later on in the program I change my mind and I want to write to a file instead of reading it. Yes, I could just say 'r+w' when opening the file, but what if I don't know if I'm going to do both? What if I have the user decide, and then later on I let the user change this.

Is it possible to do so without opening the file again and using the same file object?

Thanks!



More information about the Python-list mailing list