title: What does urllib.request.urlretrieve do if not returned
body: <p>From the python document, it is mentioned that <code>urllib.request.urlretrieve</code> returns a tuple and will be used to open file as shown in Code-A below.</p>
  <p>However in the example Code-B. The <code>urllib.request.urlretrieve</code> does not return but the code will fail without it. Please help clarify what does <code>urllib.request.urlretrieve</code> doing in Code B. THanks</p>
  <p>Code A</p>
  <pre><code>import urllib.request
  &gt;&gt;&gt; local_filename, headers = urllib.request.urlretrieve('http://python.org/')
  &gt;&gt;&gt; html = open(local_filename)
  &gt;&gt;&gt; html.close()
  </code></pre>
  <p>Code B</p>
  <pre><code>import os
  import tarfile
  from six.moves import urllib
  
  DOWNLOAD_ROOT = &quot;https://raw.githubusercontent.com/ageron/handson-ml2/master/&quot;
  HOUSING_PATH = os.path.join(&quot;datasets&quot;, &quot;housing&quot;) # datasets\housing
  HOUSING_URL = DOWNLOAD_ROOT + &quot;datasets/housing/housing.tgz&quot;
  
  def fetch_housing_data(housing_url=HOUSING_URL, housing_path=HOUSING_PATH):
      if not os.path.isdir(housing_path):
              os.makedirs(housing_path)
      tgz_path = os.path.join(housing_path, &quot;housing.tgz&quot;) #datasets\housing\housing.tgz
      urllib.request.urlretrieve(housing_url, tgz_path) #what does this code here do?
      housing_tgz = tarfile.open(tgz_path)
      housing_tgz.extractall(path=housing_path)
      housing_tgz.close()
  </code></pre>