[Python-ideas] Re: Expand the try-expect syntax to support conditional expect block

2022-05-20 Thread Martin Di Paola
You probably already saw the syntax but it is not common in the "except" part: For example, the following: catch_everything = True try: raise Exception() except Exception if catch_everything else (): print("Caught!") It is the same as: catch_everything = True exception_to_catch = Excepti

[Python-ideas] Re: Generalized deferred computation in Python

2022-06-22 Thread Martin Di Paola
Hi David, I read the PEP and I think it would be useful to expand the Motivation and Examples sections. While indeed Dask uses lazy evaluation to build a complex computation without executing it, I don't think that it is the whole story. Dask takes this deferred complex computation and *plans* h

[Python-ideas] Re: Generalized deferred computation in Python

2022-06-22 Thread Martin Di Paola
On Wed, Jun 22, 2022 at 02:30:14PM -0400, David Mertz, Ph.D. wrote: The difference is in composition of operations. I can write a dozen zero-argument lambdas easily enough. But those are all isolated. But basically, think about `x = (later expensive1() + later expensive2()) / later expensive3(

[Python-ideas] Re: Generalized deferred computation in Python

2022-06-22 Thread Martin Di Paola
On Wed, Jun 22, 2022 at 11:22:05PM +0100, Paul Moore wrote: Hang on, did the PEP change? The version I saw didn't have a compute() method, deferred objects were just evaluated when they were referenced. You are right, the PEP does not mention a compute() method but uses the that term. I just

[Python-ideas] Re: [Python-ideas][RESEND] PEP Idea: native f-string support as a match pattern

2022-08-14 Thread Martin Di Paola
The proposal can be more tricker than one may think. Leave aside the precision and width specification that f'{foo:02.f'} can get. Leave even aside the pattern match syntax. Suppose the following pattern (to differentiate it from f-string I'm going to use p-strings) pattern = p"Your id is {id}