Advertisement
Guest User

Untitled

a guest
Sep 26th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. def select_cell(notebook, out_value):
  2. """
  3. returns the information of a cell
  4. """
  5.  
  6. # Notebook formatting defintions
  7. if notebook["nbformat"] < 4:
  8. cell_all = list(notebook["worksheets"][0]["cells"])
  9. key_counter = 'prompt_number'
  10. else:
  11. cell_all = list(notebook["cells"])
  12. key_counter = 'execution_count'
  13.  
  14. # Finding and returning the relevant cell
  15. for icell, cell in enumerate(cell_all):
  16. try: # Not all Cells have the `key_counts`
  17. if cell[key_counter] == out_value:
  18. return cell
  19. except:
  20. None
  21.  
  22. return None
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement