mode for file created by open

Chris Angelico rosuav at gmail.com
Sat Jun 9 12:32:09 EDT 2012


On Sun, Jun 10, 2012 at 12:08 AM, Devin Jeanpierre
<jeanpierreda at gmail.com> wrote:
> I do, although I'm hesitant, because this only applies when mode ==
> 'w', and open has a large and growing list of parameters.

True, but keyword arguments don't cost much complexity.

open(file, mode='r', buffering=-1, encoding=None, errors=None,
newline=None, closefd=True)

I don't think this would be hurt by another parameter, since most of
them will be happily ignored by most calls. It's not like opening
files in assembly language under OS/2, where it takes thirteen pushes
for each call (arguments on the stack, make sure you push them in the
right order, don't forget that pointers require a segment and an
offset and make sure they're the right way around). File handling IS
complex, so it stands to reason that the file-open function should
carry that complexity.

ChrisA



More information about the Python-list mailing list