parameters: (file, flag='r', mode=0666)
return_statement: return mod.open(file, flag, mode)
docstring: Open or create database at path given by *file*.
  
      Optional argument *flag* can be 'r' (default) for read-only access, 'w'
      for read-write access of an existing database, 'c' for read-write access
      to a new or existing database, and 'n' for read-write access to a new
      database.
  
      Note: 'r' and 'w' fail if the database doesn't exist; 'c' creates it
      only if it doesn't exist; and 'n' always creates a new database.
docstring_summary: Open or create database at path given by *file*.
docstring_tokens: Open or create database at path given by * file * .
function: def open(file, flag='r', mode=0666):
      """Open or create database at path given by *file*.
  
      Optional argument *flag* can be 'r' (default) for read-only access, 'w'
      for read-write access of an existing database, 'c' for read-write access
      to a new or existing database, and 'n' for read-write access to a new
      database.
  
      Note: 'r' and 'w' fail if the database doesn't exist; 'c' creates it
      only if it doesn't exist; and 'n' always creates a new database.
      """
  
      # guess the type of an existing database
      from whichdb import whichdb
      result=whichdb(file)
      if result is None:
          # db doesn't exist
          if 'c' in flag or 'n' in flag:
              # file doesn't exist and the new
              # flag was used so use default type
              mod = _defaultmod
          else:
              raise error, "need 'c' or 'n' flag to open new db"
      elif result == "":
          # db type cannot be determined
          raise error, "db type could not be determined"
      else:
          mod = __import__(result)
      return mod.open(file, flag, mode)
function_tokens: def open ( file , flag = 'r' , mode = 0666 ) : # guess the type of an existing database from whichdb import whichdb result = whichdb ( file ) if result is None : # db doesn't exist if 'c' in flag or 'n' in flag : # file doesn't exist and the new # flag was used so use default type mod = _defaultmod else : raise error , "need 'c' or 'n' flag to open new db" elif result == "" : # db type cannot be determined raise error , "db type could not be determined" else : mod = __import__ ( result ) return mod . open ( file , flag , mode )