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

[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, and

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

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

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

[Python-ideas] Proposal to associate thread-local data/context with a faulthandler traceback

2022-03-05 Thread tom
The faulthandler module is invaluable for tracking down segfaults in native code, however it is really lacking the ability to add some kind of useful breadcumb to aide debugging. Imagine you are running a large-scale distributed job over tens of millions of images and a single one causes opencv

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

[Python-ideas] Re: Proposal to associate thread-local data/context with a faulthandler traceback

2022-03-05 Thread Barry Scott
> On 2 Mar 2022, at 14:22, [email protected] wrote: > > The faulthandler module is invaluable for tracking down segfaults in native > code, however it is really lacking the ability to add some kind of useful > breadcumb to aide debugging. Imagine you are running a large-scale > distributed job

[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 "too

[Python-ideas] Re: Proposal to associate thread-local data/context with a faulthandler traceback

2022-03-05 Thread tom
> Until you have this have you considered turning on core dumps? Then you will > be able to see the image id in the dump file. Alternatively you could write the context to a file. Then log the contents of the file in a wrapper script that handlers python exiting on SEGV. > I understand what you