[Python-ideas] Re: Syntax proposal of for..in..if in regular for loops

2022-03-04 Thread Steven D'Aprano
This post is rather off topic. If you don't want to get bogged down in philosophical arguments, you might want to skip this one and come back to my next reply, which I promise will be more on top. On Fri, Mar 04, 2022 at 04:39:12AM +1100, Chris Angelico wrote: > > They also do a better job of

[Python-ideas] Re: Syntax proposal of for..in..if in regular for loops

2022-03-04 Thread Christopher Barker
> > In the status quo, we have a filtered loop written as: > > > > for item in items: > > if condition: > > block The thing is, if block is more than a couple lines, you need to look down to see if there’s an else or any number of elif blocks down there— so this isn’t a cl

[Python-ideas] Re: Syntax proposal of for..in..if in regular for loops

2022-03-04 Thread Chris Angelico
On Sat, 5 Mar 2022 at 04:34, Christopher Barker wrote: > > >> > In the status quo, we have a filtered loop written as: >> > >> > for item in items: >> > if condition: >> > block > > > The thing is, if block is more than a couple lines, you need to look down to > see if the

[Python-ideas] Re: Add function for reading a specific number of bytes/characters from a file object that fails noisily

2022-03-04 Thread Steven D'Aprano
On Thu, Mar 03, 2022 at 08:09:00AM -0800, Christopher Barker wrote: > Rather than a new function, maybe a flag? https://martinfowler.com/bliki/FlagArgument.html https://alexkondov.com/should-you-pass-boolean-to-functions/ -- Steve ___ Python-ideas

[Python-ideas] Re: Add function for reading a specific number of bytes/characters from a file object that fails noisily

2022-03-04 Thread Chris Angelico
On Fri, 4 Mar 2022 at 12:10, Christopher Barker wrote: > > On Thu, Mar 3, 2022 at 9:58 AM Kevin Mills wrote: >> >> I actually initially was going to suggest a `strict` flag get added, but I >> figured that would be impractical. I was mostly concerned about classes that >> mimic file objects, be