Package: tutormagic
tutormagic extension for the Jupyter notebookRecommendationHave a look tonbtutor, a more polished and better solution.Jupyter notebook magics to embedhttp://www.pythontutor.comwithin an IFrame in
the Jupyter notebook or to open a new tab in the browser using the code from a
notebook code cell (using the IPython kernel).Installpipinstalltutormagicor with condacondainstall-ckikocorreosotutormagicor (for the development version)pipinstallgit+https://github.com/kikocorreoso/tutormagic.gitTested on Python 2.7.x/3.4.x/3.5.x/3.6.x/3.7.x/3.8.x/3.9.x and Jupyter 3.x/4.x/5.x/6.x.UsageFirst, load the extension:%load_exttutormagicOnce loaded, in a code cell in the notebook type the following:%%tutor--langpython3# some python code# ...to create an IFrame within the notebook with thehttp://www.pythontutor.compage
with the code included in the Jupyter code cell or:%%tutor--langpython3--tab# some python code# ...to openhttp://www.pythontutor.compage in a new browser tab with the code
included in the Jupyter code cell.Options--langor-l: it allows you to
choose one of the available languages supported bypythontutor. If this option is not used then
it will consider the code in the cell as Python3 code.%%tutor--langpython3or%%tutor-lpython3or%%tutorto show a pythontutor IFrame withpython3code.%%tutor--langpython2or%%tutor-lpython2to show a
pythontutor IFrame withpython2code.%%tutor--langpy3anacondaor%%tutor-lpy3anacondato show a
pythontutor IFrame withpy3anacondacode. This option allows you to import libs likenumpy. This is experimental.%%tutor--langjavaor%%tutor-ljavato show a pythontutor
IFrame withjavacode.%%tutor--langjavascriptor%%tutor-ljavascriptto show a
pythontutor IFrame withjavascriptcode.%%tutor--langtypescriptor%%tutor-ltypescriptto show a
pythontutor IFrame withtypescriptcode.%%tutor--langrubyor%%tutor-lrubyto show a
pythontutor IFrame withrubycode.%%tutor--langcor%%tutor-lcto show a
pythontutor IFrame withccode.%%tutor--langc++or%%tutor-lc++to show a
pythontutor IFrame withc++code.--heightor-h: it changes the height of the output area display in pixels. It is used to define the height of the IFrame used to embedhttp://pythontutor.comwithin the notebook. If the–taboption is used
this option will be ignored.--tabor-t: it will openhttp://pythontutor.comin a new tab
instead of within an IFrame within the notebook.--secureor-s: it will use HTTPS to open PythonTutor.com. This is useful when being used in a notebook that uses SSL.--linkor-k: it will display a link to PythonTutor, not via an iFrame.--runor-r: Use this option if you also want to run the code in the cell in the notebook.You can customize how PythonTutor is rendered via the options available below in the URL params. The following options are available:Use the--cumulativeoption to tell PythonTutor to the cumulative to TrueUse the--heapPrimitivesoption to tell PythonTutor to render objects on the heapUse the--textReferencesoption to tell PythonTutor to use text labels for referencesUse the--curInstrfollowed by a number to start the visualisation at the defined stepUse the--verticalStackto set visualization to stack atop one another.ExamplesExample notebook included in the repository.Example (in spanish)
notebook.Name of the extensionThe name of the extension was suggested by Doug S. Blank
(@dsblank).ChangelogVersion 0.3.1Added option–lang py3anaconda(thanks to@naereen).Version 0.3.0Added options--secure,--link,--cumulative,--heapPrimitivesand--textReferences(thanks to James Quacinella (@jquacinella)).Added options--run,--curInstrand--verticalStack.Version 0.2.0Added new--taboption (thanks to Holger Karl (@hkarl)).Added new--heightoption (thanks to Tom Simonart(@tomsimonart)).Added new languages available onhttp://pythontutor.com(Typescript, Ruby, C and C++).Version 0.1.0Initial version