Re: [Python-ideas] shutil.symlink - "avoid constant bool flags"

2019-05-16 Thread Greg Ewing
Tom Hale wrote: It seems far more practicable to have only two functions with sensible boolean defaults, with the split being based on the underlying os module function, namely os.link and os.symlink. Also the os module is designed to follow the C API of the OS as closely as practicable, so

Re: [Python-ideas] Passing positional arguments as keyword arguments (to provide function arguments out of order)

2019-05-16 Thread Anders Hovmöller
> On 16 May 2019, at 08:50, Serhiy Storchaka wrote: > > 16.05.19 08:46, Anders Hovmöller пише: >> In the general case because of features that until / was introduced was >> unique to functions defined in C. But in the case of the dict constructor >> that's just a weird misfeature. If it did

Re: [Python-ideas] shutil.symlink to allow non-race replacement of existing link targets

2019-05-16 Thread Tom Hale
Let me prefix all of this by saying that a shutil.symlink_with_overwrite is useful (see below), but limited in scope. Please see my next post on emulating POSIX ln. On 16/5/19 2:02 pm, Serhiy Storchaka wrote: This may be an interesting project on PyPi, but I do not think that we need to

[Python-ideas] Implement POSIX ln via shutil.link and shutil.symlink

2019-05-16 Thread Tom Hale
Thanks to all who have contributed to the discussion so far. I've noticed that the documentation[1] for both os.link and os.symlink doesn't mention that the "dst" filename should not exist. Also omitted from the documentation of both is any mention of "FileExistsError". Taking a step back, I

Re: [Python-ideas] shutil.symlink to allow non-race replacement of existing link targets

2019-05-16 Thread Serhiy Storchaka
16.05.19 14:33, Antoine Pitrou пише: On Thu, 16 May 2019 13:05:48 +0300 Serhiy Storchaka wrote: 16.05.19 11:28, Barry Scott пише: To replace one symlink with another atomically is possible by using rename() or renameat() something like: os.symlink( src, tmp_symlink )

Re: [Python-ideas] shutil.symlink - "avoid constant bool flags"

2019-05-16 Thread Tom Hale
On 14/5/19 12:38 am, Steven D'Aprano wrote: On Mon, May 13, 2019 at 12:31:08PM +0200, Anders Hovmöller wrote: An optional "overwrite_if_exists=False" flag seems much nicer. Aside from the argument name being too verbose, that violates the rule of thumb "avoid constant bool flags" design

Re: [Python-ideas] shutil.symlink to allow non-race replacement of existing link targets

2019-05-16 Thread Antoine Pitrou
On Thu, 16 May 2019 16:04:36 +0300 Serhiy Storchaka wrote: > 16.05.19 14:33, Antoine Pitrou пише: > > On Thu, 16 May 2019 13:05:48 +0300 > > Serhiy Storchaka > > wrote: > >> 16.05.19 11:28, Barry Scott пише: > >>> To replace one symlink with another atomically is possible by using > >>>

Re: [Python-ideas] shutil.symlink to allow non-race replacement of existing link targets

2019-05-16 Thread Serhiy Storchaka
16.05.19 11:28, Barry Scott пише: To replace one symlink with another atomically is possible by using rename() or renameat() something like: os.symlink( src, tmp_symlink ) os.rename( tmp_symlink, dst ) Somebody can replace tmp_symlink between os.symlink() and os.rename().

Re: [Python-ideas] shutil.symlink to allow non-race replacement of existing link targets

2019-05-16 Thread Antoine Pitrou
On Thu, 16 May 2019 13:05:48 +0300 Serhiy Storchaka wrote: > 16.05.19 11:28, Barry Scott пише: > > To replace one symlink with another atomically is possible by using > > rename() or renameat() > > something like: > > > > os.symlink( src, tmp_symlink ) > > os.rename( tmp_symlink, dst )

Re: [Python-ideas] shutil.symlink to allow non-race replacement of existing link targets

2019-05-16 Thread Barry Scott
> On 16 May 2019, at 11:05, Serhiy Storchaka wrote: > > 16.05.19 11:28, Barry Scott пише: >> To replace one symlink with another atomically is possible by using rename() >> or renameat() >> something like: >> os.symlink( src, tmp_symlink ) >> os.rename( tmp_symlink, dst ) > >

Re: [Python-ideas] A plea for people to please remember to assume good faith

2019-05-16 Thread Serge Matveenko
On Thu, May 16, 2019 at 10:41 AM Steven D'Aprano wrote: > - try to assume the author of emails is writing in good faith I have a piece of advice I often give to teams. When you catch yourself in a conversation on a thought like "how can I convince an opponent that I'm right" try first to think

Re: [Python-ideas] shutil.symlink to allow non-race replacement of existing link targets

2019-05-16 Thread Serhiy Storchaka
14.05.19 19:50, Steven D'Aprano пише: On Tue, May 14, 2019 at 02:43:03PM +0300, Serhiy Storchaka wrote: Sorry, but I do not understand what problem do you try to solve. If somebody can create a file named link_name between unlink and symlink, he can also remove and create a file named link_name

Re: [Python-ideas] Passing positional arguments as keyword arguments (to provide function arguments out of order)

2019-05-16 Thread Serhiy Storchaka
16.05.19 08:46, Anders Hovmöller пише: In the general case because of features that until / was introduced was unique to functions defined in C. But in the case of the dict constructor that's just a weird misfeature. If it did in fact take *args and handled it it would be perfectly fine and

Re: [Python-ideas] shutil.symlink to allow non-race replacement of existing link targets

2019-05-16 Thread Barry Scott
To replace one symlink with another atomically is possible by using rename() or renameat() something like: os.symlink( src, tmp_symlink ) os.rename( tmp_symlink, dst ) Use dir_fd's to taste. I'm sure there is a lot more to cover all the corner cases and attack vectors. I'm not

Re: [Python-ideas] easier lazy logging in stdlib ?

2019-05-16 Thread Barry Scott
This came up 2 years ago. You might want to read this article on LWN that covered the discussion. https://lwn.net/Articles/716986/ Assuming that the log code you call will spot a callable and call it you can do this: log_function( lambda :

[Python-ideas] A plea for people to please remember to assume good faith

2019-05-16 Thread Steven D'Aprano
In another thread, a couple of days ago, there were a few ill-tempered[1] accusations thrown around about "rudeness" and "attitude". Please remember that email is notorious for communicating tone of voice very badly. Especially if people overcompensate by trying hard to be extra polite, which

Re: [Python-ideas] shutil.symlink to allow non-race replacement of existing link targets

2019-05-16 Thread Serhiy Storchaka
16.05.19 17:05, Antoine Pitrou пише: On Thu, 16 May 2019 16:04:36 +0300 Serhiy Storchaka wrote: 16.05.19 14:33, Antoine Pitrou пише: On Thu, 16 May 2019 13:05:48 +0300 Serhiy Storchaka wrote: 16.05.19 11:28, Barry Scott пише: To replace one symlink with another atomically is possible by

Re: [Python-ideas] shutil.symlink to allow non-race replacement of existing link targets

2019-05-16 Thread Antoine Pitrou
On Thu, 16 May 2019 18:05:39 +0300 Serhiy Storchaka wrote: > 16.05.19 17:05, Antoine Pitrou пише: > > On Thu, 16 May 2019 16:04:36 +0300 > > Serhiy Storchaka > > wrote: > >> 16.05.19 14:33, Antoine Pitrou пише: > >>> On Thu, 16 May 2019 13:05:48 +0300 > >>> Serhiy Storchaka > >>> wrote: >

Re: [Python-ideas] Passing positional arguments as keyword arguments (to provide function arguments out of order)

2019-05-16 Thread Terry Reedy
On 5/16/2019 8:23 AM, Anders Hovmöller wrote: On 16 May 2019, at 08:50, Serhiy Storchaka wrote: Writing the code that parses args is errorprone and inefficient. There are also other rationales of PEP 570. I've read it. It is unconvincing to me. That's fine. Coredevs don't always agree