0

here is javascript code

var {a,b,c}=my_dict

The code takes the some parameters from a dictionary (called object in js) and defines them as local variables so they can be easily accessed later in the function. I like the syntax because it only uses a variable name once.

My question is: is there a similar feature in python?

yigal
  • 3,923
  • 8
  • 37
  • 59
  • 2
    I don't think there is an equivalent that is as convenient as javascript here. There are some [other threads](https://stackoverflow.com/questions/2955412/destructuring-bind-dictionary-contents) with solutions that get you about half way there. – Mark Mar 30 '22 at 19:54
  • Dictionaries aren't called objects in JS, btw. The closest equivalent to a Python `dict` object is a JS `Map` object – juanpa.arrivillaga Mar 30 '22 at 19:55

0 Answers0