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

2022-03-02 Thread Rob Cliffe via Python-ideas
On 02/03/2022 20:03, David Mertz, Ph.D. wrote: I really am shocked by how many people seem to have broken ENTER keys on their keyboards. You mock.  (As far as I remember you have always opposed new language features/changes.  Correct me if I am wrong.) But the proposal would give people the c

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

2022-03-02 Thread Rob Cliffe via Python-ideas
On 02/03/2022 20:03, David Mertz, Ph.D. wrote: I really am shocked by how many people seem to have broken ENTER keys on their keyboards. You mock.  (As far as I remember you are always opposed to new language features/changes.) But the proposal would give people the choice of     Saving a lev

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

2022-03-02 Thread Rob Cliffe via Python-ideas
I have had precisely the same idea. It feels better to make this feature general (if introduced at all) than make it specific to 'for' + 'if'. I think there would have to be a rule that any 'if' that appeared on a line with other suite-introducing-statements could not have a corresponding 'else

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

2022-03-02 Thread Steven D'Aprano
On Wed, Mar 02, 2022 at 09:25:01AM -0500, Ricky Teachey wrote: > Is there some opportunity for some kind of compiler magic when the iterable > of a for loop is fully contained in a place easily findable by the > compiler, and not spread over multiple if and for statements? I am not an expert on c

[Python-ideas] Re: repeat until

2022-03-02 Thread Ben Rudiak-Gould
On Tue, Mar 1, 2022 at 4:51 PM Steven D'Aprano wrote: > Then Python is the wrong language for you, because it uses exceptions to > direct control flow *wink* > > The iteration protocol uses StopIteration to end iteration. The older > sequence protocol uses IndexError for the same purpose. > I th

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

2022-03-02 Thread David Mertz, Ph.D.
I really am shocked by how many people seem to have broken ENTER keys on their keyboards. Let's just keep Python readable rather than see how much we can cram on a line. On Wed, Mar 2, 2022, 2:56 PM Jeremiah Paige wrote: > I have on a few occasions wanted a for..in..if statement and if it exist

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

2022-03-02 Thread Jeremiah Paige
I have on a few occasions wanted a for..in..if statement and if it existed would have used it. However, I agree that the level of change a new statement type brings to the language is probably too high for this feature. But what if python lifted the newline requirement for blocks that contain comp

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

2022-03-02 Thread Chris Angelico
On Thu, 3 Mar 2022 at 01:28, Ricky Teachey wrote: > > I think I'm -0.5 but I have a question for the people on here smarter than me > (pretty much all): > > Is there some opportunity for some kind of compiler magic when the iterable > of a for loop is fully contained in a place easily findable b

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

2022-03-02 Thread Christopher Barker
On Wed, Mar 2, 2022 at 2:25 AM Steven D'Aprano wrote: > > I think it's really the equivalent of > > > > for x in y: > > if not x in c: > > break > > do_stuff > > > > which to me give the proposed syntax a bit more relative strength. > > Forgotten the difference between continue an

[Python-ideas] Re: shutil.copyfileobj to return number of bytes copied

2022-03-02 Thread Barry
> On 2 Mar 2022, at 13:40, Davis, Matthew via Python-ideas > wrote: > >  > Hi, > > Currently shutil.copyfileobj returns nothing. > I would like to be able to find out how many bytes were copied. > > Whilst most file-like objects have a .tell() which you could use, some don’t, > and .tell()

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

2022-03-02 Thread Ricky Teachey
I think I'm -0.5 but I have a question for the people on here smarter than me (pretty much all): Is there some opportunity for some kind of compiler magic when the iterable of a for loop is fully contained in a place easily findable by the compiler, and not spread over multiple if and for statemen

[Python-ideas] Re: Bringing the print statement back

2022-03-02 Thread Juancarlo Añez
On several functional languages that allow function invocations without enclosing arguments in parentheses all functions take a single argument. For multiple arguments the single argument is a tuple. For no arguments the single argument is an empty tuple. I've read the comments and I see more fear

[Python-ideas] shutil.copyfileobj to return number of bytes copied

2022-03-02 Thread Davis, Matthew via Python-ideas
Hi, Currently shutil.copyfileobj returns nothing. I would like to be able to find out how many bytes were copied. Whilst most file-like objects have a .tell() which you could use, some don’t, and .tell() is not guaranteed to measure the number of bytes, it could measure with other units. I don

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

2022-03-02 Thread Dennis Sweeney
I've heard "evaluation map" for a related mathematical concept: the natural map from X to (X -> Y) -> Y in some cartesian closed category (whatever that means :-), like the natural embedding of a vector space into its double dual space, or like this sort of eval_at function that you can then plu

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

2022-03-02 Thread Paul Moore
On Wed, 2 Mar 2022 at 10:27, Steven D'Aprano wrote: > Off-topic, but since you raised the issue... is there a standard > functional programming term for a variant of map() that applies a single > argument to a series of different functions? > > # regular map > map(func, list_of_args) # (

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

2022-03-02 Thread Steven D'Aprano
On Tue, Mar 01, 2022 at 09:27:05PM -0800, Christopher Barker wrote: > I think it's really the equivalent of > > for x in y: > if not x in c: > break > do_stuff > > which to me give the proposed syntax a bit more relative strength. Forgotten the difference between continue and br

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

2022-03-02 Thread Steven D'Aprano
On Wed, Mar 02, 2022 at 05:01:38PM +0900, Stephen J. Turnbull wrote: > My 63-year-old eyes struggle with 80-character lines, but in all > fairness to those with better eyesight I'm not going to argue for > Mom's 65[1]. This is a very good point that the "80 columns is too short" crowd forget. 80

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

2022-03-02 Thread Stephen J. Turnbull
Michael Smith writes: > This is just a small improvement, but worthwhile. It's intuitive IMO to be > able to use similar filtering expressions to comprehensions at the top of a > for loop. Intuitive I guess, but in comprehensions it was "strictly from need" since comprehension syntax is an exp