title: How do I make code save local variables between its processes in python like ipython notebook does?
body: <p>I think my title isn't clear so... I made this code which fetches top Dota TV games as an array of these match_ids and prints them in the end. <code>STEAM_LGN</code>, <code>STEAM_PSW</code> are steam login/password combination.</p>
  <pre><code>from steam.client import SteamClient
  from dota2.client import Dota2Client
  
  client = SteamClient()
  dota = Dota2Client(client)
  
  @client.on('logged_on')
  def start_dota():
      dota.launch()
  
  match_ids = []
  @dota.on('top_source_tv_games')
  def response(result):
      for match in result.game_list: # games
          match_ids.append(match.match_id)  
      
  def request_matches():
      dota.request_top_source_tv_games()
  
  client.cli_login(username=STEAM_LGN, password=STEAM_PSW)
  
  request_matches()
  dota.on('top_source_tv_games', response)
  print(match_ids)
  </code></pre>
  <p>The thing I'm having a problem with</p>
  <p>When using Anaconda iPython Notebook -&gt; when I run the cell for the first time -&gt; it returns me</p>
  <p><code>[]</code></p>
  <p>but when I do it for the second time, it returns me a real data, for example</p>
  <p><code>[5769568657, 5769554974, 5769555609, 5769572298, 5769543230, 5769561446, 5769562113, 5769552763, 5769550735, 5769563870]</code></p>
  <p>So every time when I am playing in my ipython notebook sandbox -&gt; I hit <code>Shift+Enter</code> twice and get the data.</p>
  <p>But now I need to tranfer this code to a bigger project. So for example let's say I save that code to <code>dota2.info.py</code> file and have this code in another file referencing <code>dota2.info.py</code>:</p>
  <pre><code>import subprocess
  import time 
  
  ### some code ###
  
  while(True):
      subprocess.call(['python', './dota2info.py'])
      time.sleep(10)
  </code></pre>
  <p>And when running project code this always prints <code>[]</code> like it was doing on first <code>Shift+Enter</code> cell-running in Anaconda ipython notebook.</p>
  <pre><code>[]
  [] 
  []
  ...
  </code></pre>
  <p>So my question is what should I do in this situation ? How can I solve this problem of (I don't know) ValvePython/dota2 code caching some important data in local unknown to me variables in ipython notebook?</p>
  <p>Ideally I want the code immediately give me real data without having these <code>[]</code>.</p>