←back to thread

620 points tambourine_man | 1 comments | | HN request time: 0.206s | source
Show context
nikisweeting ◴[] No.43753737[source]
This is pretty cool, if we're porting JS features do we get dictionary unpacking/destructuring next?

I just want this so badly, it's the main reason I drift back to JS:

    >>> {a, b=45, c=None, **d} = {'a': 234, xzy: 32456}
    >>> print(a, b, c, d)
    234 45 None {'xyz': 32456}
replies(2): >>43754187 #>>43757011 #
1. enragedcacti ◴[] No.43754187[source]
just use this very sane pattern /s:

    >>> match {'b': 45, 'c': None}|{'a': 234, 'xyz': 32456}:
    >>>     case {'a': a, 'b': b, 'c': c, **d}: pass
    >>> print(a, b, c, d)
    234 45 None {'xyz': 32456}