[Python-ideas] Re: Syntax for loop invariants

2020-03-18 Thread Kyle Stanley
I'd have to agree with Steven here, I'm -0 on the proposal since it's not convincing (at least at the moment). haael wrote: > Python has more and more optional tools for formal correctness cheking. > Why not loop invariants? A better question would be "why add loop invariants?" rather than "why n

[Python-ideas] Syntax for loop invariants

2020-03-18 Thread Stephen J. Turnbull
haael writes: > Loop invariant is such a statement that if it was true before the loop > iteration, it will also be true after the iteration. It can be > implemented as an assertion of an implication. > > now_value = False > while running_condition(...): > prev_value =

[Python-ideas] Re: Syntax for loop invariants

2020-03-18 Thread haael
I am making a library that is able to prove that a function (without side effects) is correct for every input, without explicitly calling it on every input. It's quite similar to what Klee does to LLVM programs. https://klee.github.io/ Klee (and my solution too) works by unrolling loops. Tha

[Python-ideas] Re: New explicit methods to trim strings

2020-03-18 Thread Rob Cliffe via Python-ideas
Consider that the start or end of a string may contain repetitions of an affix. Should `-+-+-+Spam'.stripprefix('-+')  remove just the first occurence?  All of them?  Does it need a 'count' parameter? [all modulo bikeshedding on the names of course] Rob Cliffe __

[Python-ideas] Re: New explicit methods to trim strings

2020-03-18 Thread Alex Hall
Just the first occurrence. The vast majority of the time, that's what people want to do, and they will usually forget to add a 'count' parameter. Many people probably wouldn't even know it exists. It would be disastrous if code did the correct thing 99.9% of the time but occasionally silently mutil

[Python-ideas] Re: New explicit methods to trim strings

2020-03-18 Thread Alex Hall
str.replace is in the opposite situation: 1. People usually want to replace everything. When I search for uses of replace in code, I can't find any uses of the count parameter. 2. People are more likely to accidentally notice that everything is being replaced the string being replaced

[Python-ideas] Re: New explicit methods to trim strings

2020-03-18 Thread Barry Scott
> On 18 Mar 2020, at 18:03, Rob Cliffe via Python-ideas > wrote: > > Consider that the start or end of a string may contain repetitions of an > affix. > > Should `-+-+-+Spam'.stripprefix('-+') remove just the first occurence? All > of them? Does it need a 'count' parameter? The only wa

[Python-ideas] Re: Syntax for loop invariants

2020-03-18 Thread Andrew Barnert via Python-ideas
> On Mar 18, 2020, at 04:22, haael wrote: > > What is bugging me is the assymetry: there is a nice way to hint functions, > but there is none to hint loops. Then Steve’s suggestion of a context manager seems perfect. It allows you to hint any statement, including a loop statement, by adding wh