On 2018-05-24 18:08, George Leslie-Waksman wrote:
I have had plenty of instances where destructuring a mapping would have
be convenient. Relating to iterable destructuring, I would expect the
syntax to be of the form "variable: key". I also think the curly-braces
make it harder to visually parse what's going on. So I might suggest
something a little like:
objkey = object()
mydict = {'a': 1, 'b': 2, 'c': 3, 4: 5, None: 6, objkey: 7}
var1: 'a', var2: 4, var3: None, var4: objkey, **rest = mydict
The problem there is that the key and the value are now the wrong way
round...
assert var1 == 1
assert var2 == 5
assert var3 == 6
assert var4 == 7
assert rest == {'b': 2, 'c': 3}
On Thu, May 24, 2018 at 9:37 AM Serhiy Storchaka <storch...@gmail.com
<mailto:storch...@gmail.com>> wrote:
24.05.18 18:46, Neil Girdhar пише:
> p = parameters.pop('some_parameter')
> q = parameters.pop('some_other_parameter')
> if parameters:
> raise ValueError
>
> parameters is a Mapping subclass and I don't want to destroy it
Oh, right. It works if parameters is a var-keyword parameter.
def __init__(self, some_kwarg, some_other_kwargs, **parameters):
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/