[Ilugc] Regarding Python File Function
- From: andyetitmoves@xxxxxxxxx (R.Ramkumar)
- Date: Fri Apr 27 13:11:30 2007
How will one open a file with a mode "always create the file"
You cannot "always create the file" as the file could exist already...
Three solutions if the file already exists:
1. Truncate the file: Use "w"
2. Append to the file: Use "w+"
3. Return with the error: Not sure how to do this with fopen. But the
UNIX open with flags O_CREAT and O_EXCL will serve the purpose.
it moves on..
--
One of the main causes of the fall of the Roman Empire
was that, lacking zero, they had no way to indicate
successful termination of their C programs.
-- Robert Firth
Other related posts: