Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to do block-comments in Google Colab?

In Jupyter notebooks you can toggle/comment a block of selected code with ^/ (ie Cntrl-/) .. this doesn't work in Google Colab notebooks. Is there a way to comment out several lines of Python code easily in a Colab notebook?

I've looked in the docs, but come up short.

like image 516
Levon Avatar asked Dec 30 '19 19:12

Levon


People also ask

How do I block comments in Python?

Using multiple single # line comments to add a block comment in Python. The most common way to comment out a block of code in Python is using the # character. Any line of code starting with # in Python is treated as a comment and gets ignored by the compiler.

What is Ctrl M in Colab?

Useful Keyboard Shortcuts in Google Colab Command. Shortcut. Create cell. Command/Ctrl+M+B. Select all cells.

How do you comment all lines in a colab Python?

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


1 Answers

In the default Colab keyboard shortcuts, you can block comment text using Ctrl+/.

If this does not work for you, check Tools->Keyboard Shortcuts and search for "Comment Current Line" to see what the shortcut is within your current settings.

like image 58
jakevdp Avatar answered Oct 29 '22 01:10

jakevdp