Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I block comment in Jupyter notebook? [closed]

I want to comment out a block of multiple lines in Jupyter Notebook, but can't find out how to do that in this current version.
It used to be in one of the drop down menus but is no longer there.
How do you comment out multi-line blocks of code at once?

This is not a duplicate because the solution given in the following link doesn't seem to work anymore:
How can I block comment code in the IPython notebook?

Ctrl + / does nothing.

like image 995
chrisfs Avatar asked Apr 27 '15 00:04

chrisfs


People also ask

How do you block comments in a Jupyter notebook?

All you need to do, is select all the lines you want to comment and press Ctrl + / as shown in below video.

How do you block comments in Python?

Python does not have any built-in mechanism for writing multiline comments. To write multiline comments in Python, prepend a # to each line to block comments. That means writing consecutive single-line comments. Start every line with the # sign consecutively, and you will achieve multiline comments.

What does %% capture do?

Capturing Output With %%capture IPython has a cell magic, %%capture , which captures the stdout/stderr of a cell. With this magic you can discard these streams or store them in a variable. By default, %%capture discards these streams. This is a simple way to suppress unwanted output.


1 Answers

Ctrl + / works for me in Chrome browser in MS Windows. On a Mac, use Cmd + / (thanks Anton K).


Please note, if / did not work out of the box, try pressing the / key on the Numpad. Credit: @DreamFlasher in comments to this question.

like image 52
user5036413 Avatar answered Sep 25 '22 10:09

user5036413