python - Variable Explorer in Jupyter Notebook -


is there variable explorer in jupyter (ipython) in spyder? uncomfortable having print list of variables time each time run through test code.

has feature been implemented yet? if so, how enable it?

update

scroll down section labeled update less convoluted method.

old answer

here notebook on how make own variable inspector. think written when jupyter notebook called ipython notebook works on latest version.

i'll post code below in case link breaks.

import ipywidgets widgets # loads widget framework. ipython.core.magics.namespace import namespacemagics # used query namespace.  # example, hide these names, avoid polluting namespace further get_ipython().user_ns_hidden['widgets'] = widgets get_ipython().user_ns_hidden['namespacemagics'] = namespacemagics  class variableinspectorwindow(object):     instance = none  def __init__(self, ipython):     """public constructor."""     if variableinspectorwindow.instance not none:         raise exception("""only 1 instance of variable inspector can exist @              time.  call close() on active instance before creating new instance.             if have lost handle active instance, can re-obtain             via `variableinspectorwindow.instance`.""")      variableinspectorwindow.instance = self     self.closed = false     self.namespace = namespacemagics()     self.namespace.shell = ipython.kernel.shell      self._box = widgets.box()     self._box._dom_classes = ['inspector']     self._box.background_color = '#fff'     self._box.border_color = '#ccc'     self._box.border_width = 1     self._box.border_radius = 5      self._modal_body = widgets.vbox()     self._modal_body.overflow_y = 'scroll'      self._modal_body_label = widgets.html(value = 'not hooked')     self._modal_body.children = [self._modal_body_label]      self._box.children = [         self._modal_body,      ]      self._ipython = ipython     self._ipython.events.register('post_run_cell', self._fill)  def close(self):     """close , remove hooks."""     if not self.closed:         self._ipython.events.unregister('post_run_cell', self._fill)         self._box.close()         self.closed = true         variableinspectorwindow.instance = none  def _fill(self):     """fill self variable information."""     values = self.namespace.who_ls()     self._modal_body_label.value = '<table class="table table-bordered table-striped"><tr><th>name</th><th>type</th><th>value</th></tr><tr><td>' + \         '</td></tr><tr><td>'.join(['{0}</td><td>{1}</td><td>{2}'.format(v, type(eval(v)).__name__, str(eval(v))) v in values]) + \         '</td></tr></table>'  def _ipython_display_(self):     """called when display() or pyout used display variable      inspector."""     self._box._ipython_display_() 

run inline following:

inspector = variableinspectorwindow(get_ipython()) inspector 

make javascript pop out;

%%javascript $('div.inspector')     .detach()     .prependto($('body'))     .css({         'z-index': 999,          position: 'fixed',         'box-shadow': '5px 5px 12px -3px black',         opacity: 0.9     })     .draggable(); 

update

date: may 17 2017

somebody wrote nbextension variable inspector. source code can seen here jupyter_contrib_nbextensions.

install

pip install jupyter_contrib_nbextensions jupyter contrib nbextension install --user

enable

jupyter nbextension enable varinspector/main

here's screen-shot;

enter image description here


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -