PyCharm 2023.3 Help

Unwrapping and removing statements

PyCharm lets you quickly unwrap or extract expressions from enclosing statements. This action is available for:

Unwrap or remove a statement

  1. Place the caret at the expression you want to extract or unwrap.

  2. Choose Code | Unwrap/Remove from the main menu or press Ctrl+Shift+Delete.

  3. PyCharm shows a popup with the available actions in the current context. Statements to be extracted and statements to be removed are highlighted with different backgrounds.

    In the example below, you can do one of the following:

    • Unwrap the if statement

      Unwrap statement
    • Unwrap the for cycle

      Unwrap cycle
  4. Click the desired action or select it using the up and down arrow keys and press Enter.

Last modified: 07 March 2024