code: def writable_stream(handle):
      
      if isinstance(handle, io.IOBase) and sys.version_info >= (3, 5):
          return handle.writable()
      try:
          handle.write(b'')
      except (io.UnsupportedOperation, IOError):
          return False
      else:
          return True
docs: Test whether a stream can be written to.