[Python-ideas] Re: New clause in FOR and WHILE instead of ELSE

2020-07-14 Thread Mathew Elman
But in `for...else` the `else` call isn't always called, so changing `else` for `finally` doesn't make sense. What you're suggesting is replacing `else` with `on_finish` and adding `finally` and `on_break`. I agree that having `finally` could make the use cases of `else` clearer, but I am not conv

[Python-ideas] Re: New clause in FOR and WHILE instead of ELSE

2020-07-14 Thread Steve Barnes
Can I suggest that for loops the `else` would be a lot clearer if it was spelt `finally` as was done for PEP-0341 for try blocks and that we might possibly need one or more `on_…` clauses such as `on_break` and `on_finish` I think that this would be a lot clearer: for i in range(N): if i >

[Python-ideas] Re: Pickle security improvements

2020-07-14 Thread Random832
On Tue, Jul 14, 2020, at 21:24, Chris Angelico wrote: > I actively oppose it because it isn't possible. Anything that is safe > will not have all of pickle's functionality. A nerfed version of > pickle that can only unpickle a tiny handful of core data types is no > better than other options that a

[Python-ideas] Re: Pickle security improvements

2020-07-14 Thread Chris Angelico
On Wed, Jul 15, 2020 at 11:00 AM Steven D'Aprano wrote: > > On Wed, Jul 15, 2020 at 09:55:03AM +1000, Chris Angelico wrote: > > > At that point, you are NOT running it with the "exact same access > > permissions", are you? :) > > Indeed, and I did acknowledge that you were probably thinking about

[Python-ideas] Re: Pickle security improvements

2020-07-14 Thread Steven D'Aprano
On Wed, Jul 15, 2020 at 09:55:03AM +1000, Chris Angelico wrote: > At that point, you are NOT running it with the "exact same access > permissions", are you? :) Indeed, and I did acknowledge that you were probably thinking about a different scenario. But I was challenging your assertion that anyo

[Python-ideas] Re: Pickle security improvements

2020-07-14 Thread Chris Angelico
On Wed, Jul 15, 2020 at 9:46 AM Steven D'Aprano wrote: > > On Mon, Jul 13, 2020 at 09:56:45PM +1000, Chris Angelico wrote: > > > A pickle file (or equivalent blob in a database, or whatever) should > > be considered equally as trusted as your source code. If you're > > writing out a file that has

[Python-ideas] Re: Pickle security improvements

2020-07-14 Thread Steven D'Aprano
On Mon, Jul 13, 2020 at 09:56:45PM +1000, Chris Angelico wrote: > A pickle file (or equivalent blob in a database, or whatever) should > be considered equally as trusted as your source code. If you're > writing out a file that has the exact same access permissions as your > own source code, and th

[Python-ideas] Re: New clause in FOR and WHILE instead of ELSE

2020-07-14 Thread Mathew Elman
On Tue, 14 Jul 2020 at 12:38, Dominik Vilsmeier wrote: > On 14.07.20 09:54, Mathew Elman wrote: > > What about adding `except` to the compound loop statement? > That way in cases where there needs to be clarity you can raise a specific > exception rather than just `break`. > Keeping the logic of

[Python-ideas] Re: Access (ordered) dict by index; insert slice

2020-07-14 Thread Barry Scott
> On 13 Jul 2020, at 18:56, Paul Moore wrote: > > On Mon, 13 Jul 2020 at 18:42, Barry Scott wrote: > >> On 13 Jul 2020, at 05:55, Christopher Barker wrote: >> >> well, sure, though I have to say that I think that that's an unfortunate >> confusing thing about python dicts. IN fact, I doub

[Python-ideas] Re: New clause in FOR and WHILE instead of ELSE

2020-07-14 Thread Dominik Vilsmeier
On 14.07.20 09:54, Mathew Elman wrote: What about adding `except` to the compound loop statement? That way in cases where there needs to be clarity you can raise a specific exception rather than just `break`. Keeping the logic of why you "break" the loop inside the loop and would also allow mult

[Python-ideas] Re: New clause in FOR and WHILE instead of ELSE

2020-07-14 Thread Mathew Elman
What about adding `except` to the compound loop statement? That way in cases where there needs to be clarity you can raise a specific exception rather than just `break`. Keeping the logic of why you "break" the loop inside the loop and would also allow multiple reasons for breaking from a for loop