title: Error Handling for When a Directory Doesn't Exist
body: <p>I have a situation where I want to store MP3s in a directory, create that directory if it doesn't exist, and exit the program if the directory cannot be created. I read that <code>os.path.exists()</code> involves more of a hit to performance than <code>os.makedirs()</code>, so with that in mind I crafted the following code: </p>
  
  <pre><code>try: 
      # If directory has not yet been created
      os.makedirs('Tracks')
      with open('Tracks/' + title + '.mp3', 'w') as mp3:
          mp3.write(mp3File.content)
          print '%s has been created.' % fileName
  
  except OSError, e:
      # If directory has already been created and is accessible
      if os.path.exists('Tracks'):
          with open('Tracks/' + title + '.mp3', 'w') as mp3:
              mp3.write(mp3File.content)
              print '%s has been created.' % fileName
  
      else: # Directory cannot be created because of file permissions, etc. 
          sys.exit("Error creating 'Tracks' Directory. Cannot save MP3. Check permissions.")
  </code></pre>
  
  <p>Does this make sense? Or should I stick with the cleaner but perhaps costlier version of simply checking whether the directory exists first and then making it? 9/10 times, the directory is going to be there. </p>