←back to thread

620 points tambourine_man | 1 comments | | HN request time: 0.257s | 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. zahlman ◴[] No.43757011[source]
Another alternative:

  >>> a, b, c, d = (lambda a, b=45, c=None, **d: (a, b, c, d))(**{'a': 234, 'xyz': 32456})
The parentheses for this are admittedly a bit tricky.