[Python-ideas] Mapping unpacking assignment

2022-02-03 Thread Stephen J. Turnbull
Yurii Karabas writes: > I am proposing to add smth like JS destructing assignment to python. > Basically, it will allow unpacking any mapping (should have > __getitem__ and keys() methods) into variables. Ideas like this have been suggested before, with a number of variations on syntax (specif

[Python-ideas] Re: Mapping unpacking assignment

2022-02-03 Thread Yurii Karabas
I can, but it seems like the wrong usage of pattern matching and it requires much more code. ``` match m: case {"a": a, "b": b, **rest}: pass case _: raise ValueError ``` We can use pattern matching to unpack sequences, but we have special syntax for this: ``` s = range(1

[Python-ideas] Re: Mapping unpacking assignment

2022-02-03 Thread Piper Thunstrom
On Thu, Feb 3, 2022 at 11:51 AM Yurii Karabas <1998uri...@gmail.com> wrote: > > I am proposing to add smth like JS destructing assignment to python. > Basically, it will allow unpacking any mapping (should have __getitem__ and > keys() methods) into variables. > > Proposed syntax: > ``` > m = {"a"

[Python-ideas] Re: Adding sortedconatiners to Python or merge the ideas?

2022-02-03 Thread Abdur-Rahmaan Janhangeer
Oh hoping over to read. I glanced but have not yet read it in details ... Kind Regards, Abdur-Rahmaan Janhangeer about | blog github Mauritius ___ P

[Python-ideas] Re: Adding sortedconatiners to Python or merge the ideas?

2022-02-03 Thread Barry
> On 3 Feb 2022, at 18:53, Abdur-Rahmaan Janhangeer > wrote: > > Fine discussion but i wonder how it ended up over there. > Hoping over. Thanks for pointers! Please don’t top post. The thinking on python dev seems to be that if a package is not needed by core python then PyPI is the best pl

[Python-ideas] Mapping unpacking assignment

2022-02-03 Thread Yurii Karabas
I am proposing to add smth like JS destructing assignment to python. Basically, it will allow unpacking any mapping (should have __getitem__ and keys() methods) into variables. Proposed syntax: ``` m = {"a": 1, "b": 2, "c": 3, "d": 4} {a, b} = m # a: 1, b: 2 {a, b, **rest} = m # a: 1, b: 2, rest

[Python-ideas] Re: Adding sortedconatiners to Python or merge the ideas?

2022-02-03 Thread Abdur-Rahmaan Janhangeer
Fine discussion but i wonder how it ended up over there. Hoping over. Thanks for pointers! On Thu, 3 Feb 2022, 21:23 Damian Shaw, wrote: > This was very recently discussed at length: > https://mail.python.org/archives/list/python-...@python.org/thread/YB2JD477TKPB2HTXDW6ZXUBD6NFFFHHJ/#YB2JD477TK

[Python-ideas] Re: Adding sortedconatiners to Python or merge the ideas?

2022-02-03 Thread Damian Shaw
This was very recently discussed at length: https://mail.python.org/archives/list/python-...@python.org/thread/YB2JD477TKPB2HTXDW6ZXUBD6NFFFHHJ/#YB2JD477TKPB2HTXDW6ZXUBD6NFFFHHJ Damian (he/him) On Thu, Feb 3, 2022 at 11:51 AM Abdur-Rahmaan Janhangeer < arj.pyt...@gmail.com> wrote: > Greetings, >

[Python-ideas] Adding sortedconatiners to Python or merge the ideas?

2022-02-03 Thread Abdur-Rahmaan Janhangeer
Greetings, This library* seems to be used by many people for some treemap operations. Would it be a good idea to include it in upcoming versions? Leetcode has it by default for the lack of a similar something in Python. I did not check, but it seems other languages cater to structures better. * h