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

2022-04-03 Thread Hasan Diwan
On Tue, 1 Mar 2022 at 17:31, Svein Seldal wrote: > for x in (a for a in y if c): -1 on this form, I know it's supported, but I can see it getting ugly, i.e. for x in (a for x in (a for x in a)) # add a few more "for x in (a" and it will get messy fast > or > > it = (a for a in

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

2022-04-01 Thread brian . patrick . mccall
+1 Python has always seemed to me to allow one to completely describe exactly what you are iterating over in a for loop in the one line containing the for statement. And that is more or less the principle I tend to follow, unless the for statement simply gets to be too long. I have even used

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

2022-03-30 Thread Jeff Edwards
As someone who has read the entirety of those thread and is not a core-dev but having some experience with breaking and non-breaking changes at scale, from my perspective: 1. This is a common syntax for an existing idea that is intuitive given other existing syntax (comprehensions) 2. This would

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

2022-03-09 Thread Greg Ewing
On 8/03/22 12:32 pm, Chris Angelico wrote: All I can see is that changes get proposed on typing-sig and actually make it into the language, but changes that get proposed on python-ideas are invariably shot down in flames, Typing is an area of Python that is under active development, so it is

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

2022-03-07 Thread Paul Moore
On Mon, 7 Mar 2022 at 23:44, Chris Angelico wrote: > Not ALL typing changes are just new things in typing.py, so that > doesn't cover everything. And yes, I am sure that a lot of things get > proposed and not implemented - my point is that typing-sig is > successfully finding the good ideas and

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

2022-03-07 Thread Brendan Barnwell
On 2022-03-07 21:32, Stephen J. Turnbull wrote: Brendan Barnwell writes: > I would be happier if fewer typing-related changes made it in. I'm curious: do you use type annotations yourself? If yes, do you just prefer minimal hints to a precise typing system, or have there been changes that

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

2022-03-07 Thread Chris Angelico
On Tue, 8 Mar 2022 at 15:37, Brendan Barnwell wrote: > > On 2022-03-07 15:32, Chris Angelico wrote: > > On Tue, 8 Mar 2022 at 10:20, Brendan Barnwell wrote: > >> > >> On 2022-03-06 14:43, Chris Angelico wrote: > >> > This keeps happening. All the successful ideas seem to happen > >> > elsewhere,

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

2022-03-07 Thread Stephen J. Turnbull
Brendan Barnwell writes: > I would be happier if fewer typing-related changes made it in. I'm curious: do you use type annotations yourself? If yes, do you just prefer minimal hints to a precise typing system, or have there been changes that are actually harmful in your opinion?

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

2022-03-07 Thread David Mertz, Ph.D.
As someone else noted, few of the ideas originating on typing-sig are for syntax changes. One might argue that some are "abuse of notation." Generally they are of the sort "let's support indexing or bitwise operators on some more types" or let's let more builtin things act as types in

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

2022-03-07 Thread Finn Mason
On Mon, Mar 7, 2022, 9:12 PM Jelle Zijlstra wrote: > > > El lun, 7 mar 2022 a las 19:57, Christopher Barker () > escribió: > >> On Mon, Mar 7, 2022 at 3:43 PM Chris Angelico wrote: >> >>> On Tue, 8 Mar 2022 at 10:39, Jelle Zijlstra >>> wrote: >>> > >>> > >>> > >>> > El lun, 7 mar 2022 a las

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

2022-03-07 Thread Brendan Barnwell
On 2022-03-07 15:32, Chris Angelico wrote: On Tue, 8 Mar 2022 at 10:20, Brendan Barnwell wrote: On 2022-03-06 14:43, Chris Angelico wrote: > This keeps happening. All the successful ideas seem to happen > elsewhere, notably on typing-sig. You seem to see that as a positive thing, but

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

2022-03-07 Thread Chris Angelico
On Tue, 8 Mar 2022 at 15:10, Jelle Zijlstra wrote: > > > > El lun, 7 mar 2022 a las 19:57, Christopher Barker () > escribió: >> >> On Mon, Mar 7, 2022 at 3:43 PM Chris Angelico wrote: >>> >>> On Tue, 8 Mar 2022 at 10:39, Jelle Zijlstra >>> wrote: >>> > >>> > >>> > >>> > El lun, 7 mar 2022 a

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

2022-03-07 Thread Jelle Zijlstra
El lun, 7 mar 2022 a las 19:57, Christopher Barker () escribió: > On Mon, Mar 7, 2022 at 3:43 PM Chris Angelico wrote: > >> On Tue, 8 Mar 2022 at 10:39, Jelle Zijlstra >> wrote: >> > >> > >> > >> > El lun, 7 mar 2022 a las 15:35, Chris Angelico () >> escribió: >> >but python-ideas is 100%

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

2022-03-07 Thread Christopher Barker
On Mon, Mar 7, 2022 at 3:43 PM Chris Angelico wrote: > On Tue, 8 Mar 2022 at 10:39, Jelle Zijlstra > wrote: > > > > > > > > El lun, 7 mar 2022 a las 15:35, Chris Angelico () > escribió: > >but python-ideas is 100% shooting ideas to pieces. 100% really? Maybe my sense of time is blurred, but

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

2022-03-07 Thread Chris Angelico
On Tue, 8 Mar 2022 at 10:39, Jelle Zijlstra wrote: > > > > El lun, 7 mar 2022 a las 15:35, Chris Angelico () escribió: >> >> On Tue, 8 Mar 2022 at 10:20, Brendan Barnwell wrote: >> > >> > On 2022-03-06 14:43, Chris Angelico wrote: >> > > This keeps happening. All the successful ideas seem to

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

2022-03-07 Thread Jelle Zijlstra
El lun, 7 mar 2022 a las 15:35, Chris Angelico () escribió: > On Tue, 8 Mar 2022 at 10:20, Brendan Barnwell > wrote: > > > > On 2022-03-06 14:43, Chris Angelico wrote: > > > This keeps happening. All the successful ideas seem to happen > > > elsewhere, notably on typing-sig. > > > > You

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

2022-03-07 Thread Chris Angelico
On Tue, 8 Mar 2022 at 10:20, Brendan Barnwell wrote: > > On 2022-03-06 14:43, Chris Angelico wrote: > > This keeps happening. All the successful ideas seem to happen > > elsewhere, notably on typing-sig. > > You seem to see that as a positive thing, but I would be happier if > fewer

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

2022-03-07 Thread Brendan Barnwell
On 2022-03-06 14:43, Chris Angelico wrote: This keeps happening. All the successful ideas seem to happen elsewhere, notably on typing-sig. You seem to see that as a positive thing, but I would be happier if fewer typing-related changes made it in. -- Brendan Barnwell "Do not follow where

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

2022-03-07 Thread Stephen J. Turnbull
Chris Angelico writes: > It's good to have a bit of inertia, so that status quo gets > maintained, but at the moment, the extent to which ideas get shot > down makes it look as if this list is python-idea-killing. This > keeps happening. I don't see lots of *good* ideas for syntax changes

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

2022-03-07 Thread Paul Moore
On Sun, 6 Mar 2022 at 22:43, Chris Angelico wrote: > > On Mon, 7 Mar 2022 at 09:33, Paul Moore wrote: > > > Do I care enough to write a PEP? No. So this, like many other small > > > ideas, will probably die on the vine. > > > > Yes, this is the real problem. It's simply not compelling enough,

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

2022-03-06 Thread David Mertz, Ph.D.
> > Earlier on the thread, I made a similar point that it would be nice to > have a way to filter without the redundant for x in x. Though I can’t think > of a really good way to express it. But as for filtered for loops: > > "for thing in > (x for x in collection if is_interesting(x))" > It's

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

2022-03-06 Thread Chris Angelico
On Mon, 7 Mar 2022 at 09:33, Paul Moore wrote: > > Do I care enough to write a PEP? No. So this, like many other small ideas, > > will probably die on the vine. > > Yes, this is the real problem. It's simply not compelling enough, even > for supporters of the idea, for them to do the necessary

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

2022-03-06 Thread Paul Moore
On Sun, 6 Mar 2022 at 21:41, Christopher Barker wrote: > > >> Personally, I'm certainly not ignoring comprehensions. "for thing in >> (x for x in collection if is_interesting(x))" uses comprehensions just >> fine, if you don't like the verbosity of "x for x in", then that's an >> issue with

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

2022-03-06 Thread Christopher Barker
> Personally, I'm certainly not ignoring comprehensions. "for thing in > (x for x in collection if is_interesting(x))" uses comprehensions just > fine, if you don't like the verbosity of "x for x in", then that's an > issue with comprehensions, not a reason why comprehensions don't > address this

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

2022-03-06 Thread Paul Moore
On Sun, 6 Mar 2022 at 01:55, Christopher Barker wrote: > > On Sat, Mar 5, 2022 at 4:33 AM Paul Moore wrote: >> >> for thing in filter(is_interesting, this_collection): >> ... >> >> That seems pretty non-clunky. Is the issue here that "filter" is not >> sufficiently well-known? Or that you

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

2022-03-05 Thread Christopher Barker
On Sat, Mar 5, 2022 at 4:33 AM Paul Moore wrote: > for thing in filter(is_interesting, this_collection): > ... > > That seems pretty non-clunky. Is the issue here that "filter" is not > sufficiently well-known? Or that you don't want to name the > is_interesting function, and lambdas are

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

2022-03-05 Thread Paul Moore
On Sat, 5 Mar 2022 at 12:43, Chris Angelico wrote: > > The throwaway function is a *terrible* idea for a lot of situations, > because it puts the condition completely out-of-line. You have to go > dig elsewhere to find out the meaning of the filter. A lambda function > can work, but is about as

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

2022-03-05 Thread Stephen J. Turnbull
Chris Angelico writes: > What Python needs is a non-clunky way to express [filtered iteration]. I don't. In my own code there aren't any else-less cases of for: if:. All the filtered iterations have intervening code at the top of the loop before the if. Most could be refactored to use

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

2022-03-05 Thread Chris Angelico
On Sat, 5 Mar 2022 at 23:32, Paul Moore wrote: > > On Sat, 5 Mar 2022 at 12:12, Chris Angelico wrote: > > > > On Sat, 5 Mar 2022 at 22:22, Stephen J. Turnbull > > wrote: > > > > > Python has one, and you've already mentioned it: > > > > > > for thing in (x for x in this_collection if

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

2022-03-05 Thread Paul Moore
On Sat, 5 Mar 2022 at 12:12, Chris Angelico wrote: > > On Sat, 5 Mar 2022 at 22:22, Stephen J. Turnbull > wrote: > > > Python has one, and you've already mentioned it: > > > > for thing in (x for x in this_collection if is_interesting(x)): > > > > It's noticably verbose, but it's an exact

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

2022-03-05 Thread Chris Angelico
On Sat, 5 Mar 2022 at 22:22, Stephen J. Turnbull wrote: > > Chris Angelico writes: > > > What Python needs is not a way to cram more onto one line. What Python > > needs is a way to express an abstract concept: "iterate over the > > interesting parts of this collection". > > Python has one,

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

2022-03-05 Thread Stephen J. Turnbull
Chris Angelico writes: > What Python needs is not a way to cram more onto one line. What Python > needs is a way to express an abstract concept: "iterate over the > interesting parts of this collection". Python has one, and you've already mentioned it: for thing in (x for x in

[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

[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

[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-03 Thread Chris Angelico
On Fri, 4 Mar 2022 at 02:48, Steven D'Aprano wrote: > > On Thu, Mar 03, 2022 at 10:30:32PM +1100, Chris Angelico wrote: > > On Thu, 3 Mar 2022 at 21:14, Steven D'Aprano wrote: > > > What did I say that made you think I denied the existence of filtered > > > iteration? Was it the post where I

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

2022-03-03 Thread Steven D'Aprano
On Thu, Mar 03, 2022 at 10:30:32PM +1100, Chris Angelico wrote: > On Thu, 3 Mar 2022 at 21:14, Steven D'Aprano wrote: > > What did I say that made you think I denied the existence of filtered > > iteration? Was it the post where I pointed out we've been able to do > > filtered iteration going

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

2022-03-03 Thread Steven D'Aprano
What I said: "Python, for good or ill, is an opinionated language regarding indentation and statements." And then Greg refuted something I never said: > So if Python is opinionated about line lengths, it's rather > selectively opinionated. The Python language isn't opinionated about line

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

2022-03-03 Thread Chris Angelico
On Thu, 3 Mar 2022 at 21:14, Steven D'Aprano wrote: > What did I say that made you think I denied the existence of filtered > iteration? Was it the post where I pointed out we've been able to do > filtered iteration going back to Python 1.x days? ANYTHING can be done by composing concepts. We

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

2022-03-03 Thread Greg Ewing
On 3/03/22 9:50 pm, Steven D'Aprano wrote: While you can put the block on the same line as the colon using semicolons: if condition: print(1); print(2) # Legal. and there's nothing to stop you from making arbitrarily long lines using this feature... if condition: print(1);

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

2022-03-03 Thread Steven D'Aprano
On Thu, Mar 03, 2022 at 08:04:57PM +1100, Chris Angelico wrote: > Python has a history of making conceptual actions shorter than the > mere combination of their parts. For instance, we don't have this > construct: > > for i in range(len(stuff)) using thing = stuff[i]: Rather than inventing new

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

2022-03-03 Thread Chris Angelico
On Thu, 3 Mar 2022 at 19:54, Steven D'Aprano wrote: > > On Thu, Mar 03, 2022 at 02:32:25AM +, Rob Cliffe via Python-ideas wrote: > > > But the proposal would give people the choice of > > Saving a level of indentation at the cost of having two > > suite-introductions on the same line. > >

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

2022-03-03 Thread Steven D'Aprano
On Thu, Mar 03, 2022 at 02:32:25AM +, Rob Cliffe via Python-ideas wrote: > But the proposal would give people the choice of >     Saving a level of indentation at the cost of having two > suite-introductions on the same line. >     Keeping the two suit-introductions on separate lines (as

[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

[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

[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

[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

[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

[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

[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

[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

[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

[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

[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

[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.

[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

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

2022-03-01 Thread Stephen J. Turnbull
Steven D'Aprano writes: > On Wed, Mar 02, 2022 at 02:28:33AM +0100, Svein Seldal wrote: > > > for x in y if x in c: > > some_op(x) > > What does this new syntax give us that we don't already have with this? > > for x in y > if x in c: > some_op(x)

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

2022-03-01 Thread Steven D'Aprano
On Tue, Mar 01, 2022 at 10:40:06PM -0500, Michael Smith wrote: > +1 > > 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. Good news! We have been able to use filtering conditions

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

2022-03-01 Thread Christopher Barker
On Tue, Mar 1, 2022 at 6:43 PM Steven D'Aprano wrote: > > for x in y if x in c: > > some_op(x) > > What does this new syntax give us that we don't already have with this? > > for x in y > if x in c: > some_op(x) > I think it's really the equivalent of for x

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

2022-03-01 Thread Michael Smith
+1 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. Here's an example: # get the Hadoop version by scanning pyspark jars. # Vague attribution: https://stackoverflow.com/a/50242383 for

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

2022-03-01 Thread David Mertz, Ph.D.
-1. Extra complexity for no benefit. Attractive nuisance to making overly complex statement lines. On Tue, Mar 1, 2022, 8:31 PM Svein Seldal wrote: > I'm sorry for reposting, but this message got stuck in moderation > approval for 5 days so I figured I should try again. > > > I'd like to

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

2022-03-01 Thread Paul Bryan
1. It aligns with existing syntax in list comprehensions and generator expressions. 2. In probably majority of cases it would be more readable to me; "iterate over iterable for items meeting condition:". 3. Could it be easier to optimize an explicit filter expression to improve iteration

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

2022-03-01 Thread Steven D'Aprano
On Wed, Mar 02, 2022 at 02:28:33AM +0100, Svein Seldal wrote: > for x in y if x in c: > some_op(x) What does this new syntax give us that we don't already have with this? for x in y if x in c: some_op(x) or the other multiple ways of writing the equivalent

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

2022-03-01 Thread Paul Bryan
Very strong +1. On Wed, 2022-03-02 at 02:28 +0100, Svein Seldal wrote: > I'm sorry for reposting, but this message got stuck in moderation > approval for 5 days so I figured I should try again. > > > I'd like to propose extending the for statement to include > conditionals > akin to