PyCharm Edu 2017.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.

Example

BeforeAfter
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. On the context menu at caret location, choose Refactor | Invert Boolean.
  3. Confirm refactoring.
Last modified: 30 March 2018