Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: mode for file created by open

16 views
Skip to first unread message

Chris Angelico

unread,
Jun 9, 2012, 12:32:09 PM6/9/12
to pytho...@python.org
On Sun, Jun 10, 2012 at 12:08 AM, Devin Jeanpierre
<jeanpi...@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

Cameron Simpson

unread,
Jun 9, 2012, 6:58:45 PM6/9/12
to Neal Becker, pytho...@python.org
On 09Jun2012 18:25, Neal Becker <ndbe...@gmail.com> wrote:
| I haven't seen the current code - I'd guess it just uses posix open.
| So I would guess it wouldn't be difficult to add the creation mode argument.
| How about call it cr_mode?

What shall it contain on Windows?
What shall it contain on Jython?
--
Cameron Simpson <c...@zip.com.au> DoD#743
http://www.cskk.ezoshosting.com/cs/

If you push something hard enough, it will fall over.
[Fudd's first law of opposition]

Cameron Simpson

unread,
Jun 9, 2012, 7:19:27 PM6/9/12
to Terry Reedy, pytho...@python.org
On 09Jun2012 19:03, Terry Reedy <tjr...@udel.edu> wrote:
| > So I would guess it wouldn't be difficult to add the creation mode argument.
|
| On posix system, probably not. On windows, just ignore it, unless 'root'
| can be mapped to 'admin'.

Oh please NO!

Either implement it correctly, or raise a ValueError if it is supplied
and not whatever means "default open".

A huge -1000 for arguments that have meaning but are ignored.

This is why I'm -1 to start with: a file permission bitmap is a
posix.open() value. It does not map portably to the general open().
This calls for a really stupid and futile gesture. - Strayhorn

Cameron Simpson

unread,
Jun 9, 2012, 6:57:14 PM6/9/12
to Neal Becker, pytho...@python.org
On 09Jun2012 07:42, Neal Becker <ndbe...@gmail.com> wrote:
| Cameron Simpson wrote:
| Doesn't anyone else think it would be a good addition to open to specify a file
| creation mode? Like posix open? Avoid all these nasty workarounds?

-1

open() is cross platform.
os.open() is platform specific, generally POSIX.
Is it true, Sen. Bedfellow, that your wife rides with bikers? - Milo Bloom
0 new messages