PyCharm 4.5.3 Help

Invert Boolean

This refactoring aims to flip the value of a Boolean variable and all its usages from True to False and vice versa.


def foo{}: abc<caret here> = True return abc
def foo{}: abc = False return not abc

To invert a boolean variable, follow these steps

  1. Place the caret at the name of a Boolean variable.
  2. Do one of the following:
    • On the main menu, choose Refactor | Invert Boolean.
    • On the context menu at caret location, choose Refactor | Invert Boolean.
  3. In the dialog box that opens, click Preview to view the suggested changes in the Find tool window, or Refactor to invert the detected occurrences silently.

See Also

Last modified: 5 August 2015