It is possible to assign the google colab notebook name to a python variable. In Jupyter you can use javascript but this does not work in colab

Viewed 1189

It is possible to assign the google colab notebook name to a python variable. In Jupyter you can use javascript but this does not work in colab. I have found examples using %javascript to access the html but these do not appear to work with colab notebooks. So I want to copy the notebook to my google drive and rename it but then assign the new name to a python variable.

1 Answers

Here's the code to get the notebook name.

from requests import get
filename = get('http://172.28.0.2:9000/api/sessions').json()[0]['name']
Related