Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create sub cell in Spyder

Is there any workaround to create sub-cells in Spyder?

E.g. I know that with

#%% Cell 1

I can create a new cell.

But is there a way to create a sub-cell which is grouped under the cell as in

# Cell 1.1

?

I have found this discussion which didn't look encouraging. But I wanted to give it a try and ask here.

like image 485
BeSeLuFri Avatar asked Jul 15 '20 08:07

BeSeLuFri


People also ask

How do you make different cells in Spyder?

Similar to Jupyter notebook, Spyder IDE allows you to create cells. To create a cell, simply put #%% in the script. Each #%% will signal generation of a new cell. To run a cell, press shift+enter while in focus of a cell.

How do you split cells in Spyder?

You can separate cells by lines starting with either: #%% (standard cell separator) # %% (standard cell separator, when file has been edited with Eclipse) # <codecell> (IPython notebook cell separator)

How do you run a cell in Spyder?

Ctrl + Enter will run the current cell. You can read more about cells in Spyder here.

How does Spyder shift multiple lines?

Select multiple lines. Move using ctrl + cmd + down-arrow-key. Lines will be deselected.


1 Answers

As per the post linked, the feature you are asking has been implemented. I just tried it on my Spyder IDE version 4.1.3 and it works by using an increasing number of %. For instance

#%% Section 1
some code

#%%% Sub-Section 1.1
some more code

#%% Section 2
and so on
like image 182
Mathieu Avatar answered Sep 20 '22 09:09

Mathieu