def _expand_user(filepath_or_buffer):
 if isinstance(filepath_or_buffer, string_types):
  return os.path.expanduser(filepath_or_buffer)
 return filepath_or_buffer

def _expand_user ( filepath_or_buffer ) : if isinstance ( filepath_or_buffer , string_types ) : return os . path . expanduser ( filepath_or_buffer ) return filepath_or_buffer
return the argument with an initial component of ~ or ~user replaced by that users home directory .