[Python-ideas] Re: Dict unpacking assignment

2020-10-30 Thread Steven D'Aprano
On Sat, Oct 24, 2020 at 09:26:23PM -, Joseph Martinot-Lagarde wrote: > Steven D'Aprano wrote: > > # Dotted names > > from types import SimpleNamespace > > obj = SimpleNamespace() > > obj.spam = **{'obj.spam': 1} > > assert obj.spam == 1 > > > > # Subscripts > > arr = [None]*5 > > arr[1], arr[3

[Python-ideas] Re: Dict unpacking assignment

2020-10-30 Thread Steven D'Aprano
On Mon, Oct 26, 2020 at 04:56:24AM -, Dennis Sweeney wrote: > What if the mapping assignment were more harmonious with the pattern matching > PEP? Something like this: > > items = {'eggs': 2, 'cheese': 3, 'spam': 1} > {'eggs': eggs, 'spam': i_dont_need_to_name_this_spam, **rest} = it