def get_file_obj(fname, mode='r', encoding=None):
 if _is_string_like(fname):
  return _open(fname, mode, encoding)
 try:
  if ('r' in mode):
   fname.read
  if (('w' in mode) or ('a' in mode)):
   fname.write
 except AttributeError:
  raise ValueError('fname must be a string or a file-like object')
 return EmptyContextManager(fname)

def get_file_obj ( fname , mode = 'r' , encoding = None ) : if _is_string_like ( fname ) : return _open ( fname , mode , encoding ) try : if ( 'r' in mode ) : fname . read if ( ( 'w' in mode ) or ( 'a' in mode ) ) : fname . write except AttributeError : raise ValueError ( 'fname must be a string or a file-like object' ) return EmptyContextManager ( fname )
light wrapper to handle strings and let files pass through .