def setStyleName(element, style, add):

    oldStyle = DOM.getAttribute(element, "className")
    if oldStyle is None:
        oldStyle = ""

    idx = findStyleName(element, style)

    if add:
        if idx == -1:
            DOM.setAttribute(element, "className", oldStyle + " " + style)
        return

    if idx == -1:
        return

    if idx == 0:
      begin = ''
    else:
      begin = oldStyle[:1-idx]

    end = oldStyle[idx + len(style):]
    DOM.setAttribute(element, "className", begin + end)
dataset/ETHPy150Open pyjs/pyjs/pyjswidgets/pyjamas/ui/UIObject.py/setStyleName/swapped operands of `-`