title: Why can't I override the default argument?
body: <p>Consider the following code:</p>
  
  <pre><code>import pickle
  
  def open_file(fname, fname1 = None):
      # returns a new OPEN file
      if fname1:
          while fname == fname1:
              f_name = input("File already open, filename: ")
      f = None
      while not f:
          try:
              f = open(fname, "rb")
          except IOError:
              fname = input("File not found, filename: ")
      print(fname, "open")
      return f
  
  def get_2cubes():
      a_name = input("\nWhat is the name of the first cube's file? ")
      a_file = open_file(a_name)
      #a_cube = pickle.load(a_file)
      a_file.close()
  
      b_name = input("\nWhat is the name of the second cube's file? ")
      b_file = open_file(b_name, a_name)
      #b_cube = pickle.load(b_file)
      b_file.close()
      #return a_cube, b_cube
  
  get_2cubes()
  </code></pre>
  
  <p>The code is meant to open a second file only if it's not the first file.</p>
  
  <p>The first file's name is represented by <code>fname1</code> in open_file(). If the name of the second file (<code>b_name</code> in this case) matches that of the first file the user will be prompted to enter a new name.</p>
  
  <p>I supplied a default argument of <code>None</code> for the <code>fname1</code> parameter because the function will sometimes be used only for opening one file and not for also comparing it to another file. However, I can't seem to override the default argument.</p>
  
  <p>The <code>a_name</code> variable from the 7th line of <code>get_2cubes</code> is not being recognized by the <code>if fname1:</code> condition in <code>open_file</code>, and as a result I can open the same file twice. How would I correct this?</p>