def iswritable(f):
 if ((not six.PY2) and hasattr(f, 'writable')):
  return f.writable()
 if (hasattr(f, 'closed') and f.closed):
  raise ValueError('I/O operation on closed file')
 if (not hasattr(f, 'write')):
  return False
 if (hasattr(f, 'mode') and (not any(((c in f.mode) for c in 'wa+')))):
  return False
 return True

def iswritable ( f ) : if ( ( not six . PY2 ) and hasattr ( f , 'writable' ) ) : return f . writable ( ) if ( hasattr ( f , 'closed' ) and f . closed ) : raise ValueError ( 'I/O operation on closed file' ) if ( not hasattr ( f , 'write' ) ) : return False if ( hasattr ( f , 'mode' ) and ( not any ( ( ( c in f . mode ) for c in 'wa+' ) ) ) ) : return False return True
returns true if the file-like object can be written to .