Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extracting the cell's index to python variable #4793

Open
YahavFes opened this issue Jul 30, 2019 · 2 comments
Open

Extracting the cell's index to python variable #4793

YahavFes opened this issue Jul 30, 2019 · 2 comments

Comments

@YahavFes
Copy link

Hi,
I would like to get the cell's index to python variable.
I know I can do this in javascript using this command:

%%javascript
var cell = Jupyter.notebook.get_selected_index()

But I need that the index will be stored in python variable.

Do you have any idea how can I solve this problem?

@rahul-ahuja1
Copy link

+1

@kolibril13
Copy link

I searched for a while, and I could not find a solution.
Workaround:
at this to the first cell:

try:
    cell_counter += 1
except NameError:
    cell_counter = 0

add this to every next cell:

cell_counter += 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants