title: Updating a globalvar dictionary derived from a globalvar list in a function, after new items adding to global var list while program is executed
body: <p>I have a global list and a global mappings dictionary</p>
  <pre><code>some_list_of_objects = []
  mapping = {i.attr1: i.attr2 for i in some_list_of_objects}
  </code></pre>
  <p>While my program runs, new objects are added to some_list_of_objects. I need my mapping dictionary to be updated after new objects are added to the list since in the later part of my program I need to access this updated mapping dictionary.</p>
  <p>I know this would be easy if I were to simply duplicate and run the mapping script. However, what I want is a function that updates the global mapping dictionary when called.</p>