← Back to context

Comment by porridgeraisin

14 hours ago

Destructuring/unpacking and packing add more to the language than whatever crap they stuff into every new python release these days. Let's never forget they _removed_ in its entirety a standard library package, that is the level we are dealing with here...

Not saying it needs to be done with the decoder hack, it should have proper compiler support, but it's basically necessary. It's the best feature in JS hands down.

  >> a, b = 2, 3 # say

  >> d = dict_of(a, b)
  >> d
  {"a": 2, "b": 3}

  >> # somewhere else...
  >> { a, b } = d
  >> a + b
  5

The dict_of() function is already possible at runtime with python `ast` magic, see [1]. That package also has unpack_keys() again made possible with `ast`, but we'd of course want proper language support.

[1] https://github.com/alexmojaki/sorcery