title: When I import a specific function from a module, that also has code in it apart from that function, it runs the entire module
body: <p>I'm trying to learn python and I've tried really hard but for some reason I can't figure this out. </p>
  
  <p>This is the module, named user_profile, where the function that I want to import comes from:</p>
  
  <pre><code>def build_profile(first, last, **user_info):
      profile = {}
      profile['first name'] = first
      profile['last name'] = last
      for key, value in user_info.items():
          profile[key] = value
      return profile
  
  user_profile = build_profile('john', 'smith', 
                              city = 'new york', 
                              occupation = 'banker', 
                              girlfriend = 'janice')
  
  for key, value in user_profile.items():
      print(key.title() + ": " + value.title())
  </code></pre>
  
  <p>Now I want to import build_profile into another module like so:</p>
  
  <pre><code>from user_profile import build_profile
  </code></pre>
  
  <p>I just want build_profile to be imported, but for some reason it runs user_profile entirely. What's going on?</p>