[Python-ideas] Re: Target-and-expression lists and if-try

2020-01-01 Thread Andrew Barnert via Python-ideas
On Jan 1, 2020, at 13:23, Random832 wrote: > > Neither of these constructs seems to be particularly useful outside the other > one, Yes, and you already quoted me as saying that. > which suggests to me they should not be orthogonal in the way you have > proposed. Is there a good reason for

[Python-ideas] Re: Target-and-expression lists and if-try

2020-01-01 Thread Andrew Barnert via Python-ideas
> On Jan 1, 2020, at 08:32, Guido van Rossum wrote: >  > Here's a proposal for JavaScript that seems to be going through > standardization: https://github.com/tc39/proposal-pattern-matching The JS solution is interesting, but I’m not sure how well it works for a different language. Python is

[Python-ideas] Re: Target-and-expression lists and if-try

2020-01-01 Thread Andrew Barnert via Python-ideas
On Jan 1, 2020, at 07:03, Steven D'Aprano wrote: > > On Tue, Dec 31, 2019 at 02:28:26PM -0800, Andrew Barnert via Python-ideas > wrote: > >>if try 0, y, z := vec: >># do yz plane stuff >>elif try x, 0, z := vec: >># do xz plane stuff >>elif try x, y, 0 := vec: >>

[Python-ideas] Re: Target-and-expression lists and if-try

2020-01-01 Thread Andrew Barnert via Python-ideas
>> On Jan 1, 2020, at 04:21, Steven D'Aprano wrote: >> >> On Tue, Dec 31, 2019 at 05:18:59PM -0800, Andrew Barnert via Python-ideas >> wrote: >> >> Some languages use special syntax to mark either values or targets: >> let x, K, let z = vec >> x, @K, z = vec >> But the simplest solution is

[Python-ideas] Re: Target-and-expression lists and if-try

2020-01-01 Thread Andrew Barnert via Python-ideas
On Dec 31, 2019, at 21:35, Guido van Rossum wrote: > > There were match proposals in the past — have you looked those up? Maybe they > solve your problem without that syntax — or maybe they would benefit from it. Most of the existing proposals require a lot more syntax—a new form using two

[Python-ideas] Re: Target-and-expression lists and if-try

2020-01-01 Thread Random832
On Tue, Dec 31, 2019, at 22:18, Andrew Barnert via Python-ideas wrote: > I’m just feeling out whether either one is so horrible that any larger > proposal (which I don’t have in anywhere near ready-to-share form yet) > would have to be rejected on that basis. (Which I think is a serious >

[Python-ideas] Re: Target-and-expression lists and if-try

2020-01-01 Thread Guido van Rossum
Here's a proposal for JavaScript that seems to be going through standardization: https://github.com/tc39/proposal-pattern-matching Here's the end of an older python-ideas thread: https://mail.python.org/archives/search?mlist=python-ideas%40python.org=pattern+matching+reprise On Tue, Dec

[Python-ideas] Re: Target-and-expression lists and if-try

2020-01-01 Thread Dan Sommers
On 1/1/20 10:02 AM, Steven D'Aprano wrote: # Fail() is a function that raises an exception; # __ is a special predefined Pattern that always matches. result = match(vec, # object to match Pattern(0, 'y', 'z'), handle_yz, Pattern('x', 0, 'z'),

[Python-ideas] Re: Target-and-expression lists and if-try

2020-01-01 Thread Steven D'Aprano
On Tue, Dec 31, 2019 at 02:28:26PM -0800, Andrew Barnert via Python-ideas wrote: > if try 0, y, z := vec: > # do yz plane stuff > elif try x, 0, z := vec: > # do xz plane stuff > elif try x, y, 0 := vec: > # do xy plane stuff > elif x, y, z := vec: >

[Python-ideas] Re: Target-and-expression lists and if-try

2020-01-01 Thread Steven D'Aprano
On Tue, Dec 31, 2019 at 05:18:59PM -0800, Andrew Barnert via Python-ideas wrote: > Some languages use special syntax to mark either values or targets: > > let x, K, let z = vec > x, @K, z = vec > > But the simplest solution is to nothing: you have to stick it in an > expression that

[Python-ideas] Re: Allow metaclass to override __subclasscheck__ for metaclass relations

2020-01-01 Thread Soni L.
On 2019-12-31 4:28 p.m., Andrew Barnert wrote: On Dec 31, 2019, at 11:02, Soni L. wrote: > > >> On 2019-12-31 3:56 p.m., Andrew Barnert wrote: >> On Dec 31, 2019, at 09:43, Soni L. wrote: >> > > I would like this code to work, but currently python ignores __subclasscheck__ in many

[Python-ideas] Re: more readable "if" for multiple "in" condition

2020-01-01 Thread Jorropo .
> This could also be resolved with any &/or all i.e.: > > if any([foo in foobar, bar in foobar, baz in foobar]): > > Or even: > > if any([l in foobar for l in [foo, bar, baz]] The goal was to have simpler syntax not a harder one, even if this already works this can't be said simpler (I

[Python-ideas] Re: more readable "if" for multiple "in" condition

2020-01-01 Thread Steve Barnes
This could also be resolved with any &/or all i.e.: if any([foo in foobar, bar in foobar, baz in foobar]): Or even: if any([l in foobar for l in [foo, bar, baz]]) but I would like to suggest allowing any & all to take more than a single argument,, i.e. if there are multiple arguments