Here are some examples :
Example 1 : One cell with navigable sections
#%% Notes
#### Defining Code Cells
# A “code cell” in Spyder is a block of lines, typically in a script, that can be
# easily executed all at once.
# You can separate cells by lines starting with either:
# 1) #%% (standard cell separator)
# 2) # %% (standard cell separator, when file has been edited with Eclipse)
# 3) # <codecell> (IPython notebook cell separator)
#### Cell heirarchy
# To nest navigable sections within a cell, use "#### ~some heading~"
# To nest subcells within a cell, use "#%% >> #%%% >> #%%%% .... "
In Outline Explorer (Spyder) appears as:
File.py
% Notes
# Section 1
# Section 2
Example 2 : Cell with subcells
#%% Main cell
#%%% Nested cell 1
#%%%% Nested(2) cell 1
#%%%% Nested(2) cell 2
#%%% Nested cell 2
Using this structure, the nested cells can be executed separately.
File.py
% Main Cell
% Nested cell 1
% Nested(2) cell 1
% Nested(2) cell 2
% Nested cell 2