title: Destructuring dicts and objects in Python
body: <p>In Javascript, I can use <a href="https://medium.com/podiihq/destructuring-objects-in-javascript-4de5a3b0e4cb" rel="noreferrer">destructuring</a> to extract properties I want from a javascript objects in one liner. For example:</p>
  <pre class="lang-js prettyprint-override"><code>currentUser = {
    &quot;id&quot;: 24,
    &quot;name&quot;: &quot;John Doe&quot;,
    &quot;website&quot;: &quot;http://mywebsite.com&quot;,
    &quot;description&quot;: &quot;I am an actor&quot;,
    &quot;email&quot;: &quot;example@example.com&quot;,
    &quot;gender&quot;: &quot;M&quot;,
    &quot;phone_number&quot;: &quot;+12345678&quot;,
    &quot;username&quot;: &quot;johndoe&quot;,
    &quot;birth_date&quot;: &quot;1991-02-23&quot;,
    &quot;followers&quot;: 46263,
    &quot;following&quot;: 345,
    &quot;like&quot;: 204,
    &quot;comments&quot;: 9
  }
  
  let { id, username } = this.currentUser;
  console.log(id) // 24
  console.log(username) //johndoe
  </code></pre>
  <p>Do we have something similar in Python for Python dicts and Python objects? Example of Python way of doing for python objects:</p>
  <pre class="lang-py prettyprint-override"><code>class User:
      def __init__(self, id, name, website, description, email, gender, phone_number, username):
          self.id = id
          self.name = name
          self.website = website
          self.description = description
          self.email = email
          self.gender = gender
          self.phone_number = phone_number
          self.username = username
    
  current_user = User(24, &quot;Jon Doe&quot;, &quot;http://mywebsite.com&quot;, &quot;I am an actor&quot;, &quot;example@example.com&quot;, &quot;M&quot;, &quot;+12345678&quot;, &quot;johndoe&quot;)
      
  # This is a pain
  id = current_user.id
  email = current_user.email
  gender = current_user.gender
  username = current_user.username
      
  print(id, email, gender, username)
  </code></pre>
  <p>Writing those 4 lines (as mentioned in example above) vs writing a single line (as mentioned below) to fetch values I need from an object is a real pain point.</p>
  <pre class="lang-py prettyprint-override"><code>(id, email, gender, username) = current_user
  </code></pre>