def fileobj_closed(f):
 if isinstance(f, string_types):
  return True
 if hasattr(f, 'closed'):
  return f.closed
 elif (hasattr(f, 'fileobj') and hasattr(f.fileobj, 'closed')):
  return f.fileobj.closed
 elif (hasattr(f, 'fp') and hasattr(f.fp, 'closed')):
  return f.fp.closed
 else:
  return False

def fileobj_closed ( f ) : if isinstance ( f , string_types ) : return True if hasattr ( f , 'closed' ) : return f . closed elif ( hasattr ( f , 'fileobj' ) and hasattr ( f . fileobj , 'closed' ) ) : return f . fileobj . closed elif ( hasattr ( f , 'fp' ) and hasattr ( f . fp , 'closed' ) ) : return f . fp . closed else : return False
returns true if the given file-like object is closed or if f is a string .