code: def open_file(file, mode):
  	
  	if hasattr(file, "read"):
  		return file
  	if hasattr(file, "open"):
  		return file.open(mode)
  	return open(file, mode)
docs: Open a file.
  
  	:arg file: file-like or path-like object.
  	:arg str mode: ``mode`` argument for :func:`open`.