Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find indentation level in Jupyter notebook?

Tags:

I am using Jupyter notebook and I have multiple loops, functions, and so on and each add one level of indentation. Sometimes I want to add a piece of code not to the last block but a few block/frame higher.

In the text editors like notebook++ there is a vertical line that determines the indentation level. Is there the same feature in Jupyter notebook?

enter image description here

like image 426
Roo Avatar asked Dec 20 '17 15:12

Roo


People also ask

How do you indent in Jupyter Notebook Markdown?

Use the greater than sign (>) followed by a space, for example: > Text that will be indented when the Markdown is rendered. Any subsequent text is indented until the next carriage return.

What is indentation error in Jupyter Notebook?

Mentioned below are some of the common causes of an indentation error in Python: While coding you are using both the tab as well as space. While in theory both of them serve the same purpose, if used alternatively in a code, the interpreter gets confused between which alteration to use and thus returns an error.


1 Answers

I would really benefit from something like this, especially when the code block gets rather long. As far as I know, there is no such thing in Jupyter, unfortunately. I was told on GitHub that the Spyder release planned for Q4 2017 would have included this, but I haven't seen it so far (Q1 2018).

If you really need to run your code on Jupyter and want to check the indentation levels, I would suggest writing your code in yhat Rodeo, check the indentation levels, and then paste your code back to Jupyter.

This is a cumbersome workaround, but at the moment it is the best thing I know that would work.

EDIT

VS Code, the free Microsoft IDE, is a valid alternative to yhat Rodeo.

like image 56
FaCoffee Avatar answered Sep 22 '22 12:09

FaCoffee