Logged In: YES
user_id=31435
The C standard is open-ended about what a mode string can
contain, and Python has historically allowed users to exploit
platform-specific extensions here. On Windows, at least 't'
and 'c' mean something in mode strings, and 'c' is actually
useful (it forces writes to get committed to disk
immediately). Most platforms ignore characters in mode
strings that they don't understand. This is an exhaustive list
of the mode strings a conforming C implementation must
support (from C99):
"""
r open text file for reading
w truncate to zero length or create text file for writing
a append; open or create text file for writing at end-of-file
rb open binary file for reading
wb truncate to zero length or create binary file for writing
ab append; open or create binary file for writing at end-of-file
r+ open text file for update (reading and writing)
w+ truncate to zero length or create text file for update
a+ append; open or create text file for update, writing at end-
of-file
r+b or rb+ open binary file for update (reading and writing)
w+b or wb+ truncate to zero length or create binary file for
update
a+b or ab+ append; open or create binary file for update,
writing at end-of-file
"""
Implementations are free to support as many more as they
care to.
Guido may be in favor of restricting Python (in 2.4 or 2.5) to
the set of mode strings required by C99, plus those that
make sense with Python's U extension. I think he said
something to that effect in person once. But 'c' is in fact
useful on Windows, and code will break if it's outlawed.
|