A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://jupyter-contrib-nbextensions.readthedocs.io/en/latest/nbextensions/snippets/README.html below:

Snippets — jupyter_contrib_nbextensions 0.5.0 documentation

jupyter_contrib_nbextensions Snippets

Code cell snippets.

This extension adds a drop-down menu to the IPython toolbar that allows easy insertion of code snippet cells into the current notebook. The code snippets are defined in a JSON file in nbextensions/snippets/snippets.json and an example snippet is included with this extension.

Adding new snippets

Snippets are specified by adding a new JSON block to the list of existing snippets in $(jupyter --data-dir)/nbextensions/snippets/snippets.json. For example, to add a new snippet that imports numpy, matplotlib, and a print statement, the JSON file should be modified from:

{
    "snippets" : [
        {
            "name" : "example",
            "code" : [
                "# This is an example snippet!",
                "# To create your own, add a new snippet block to the",
                "# snippets.json file in your jupyter data directory under nbextensions:",
                "# $(jupyter --data-dir)/nbextensions/snippets/snippets.json",
                "import this"
            ]
        }
    ]
}

to this:

{
    "snippets" : [
        {
            "name" : "example",
            "code" : [
                "# This is an example snippet!",
                "# To create your own, add a new snippet block to the",
                "# snippets.json file in your jupyter data directory under nbextensions:",
                "# $(jupyter --data-dir)/nbextensions/snippets/snippets.json",
                "import this"
            ]
        },
        {
            "name" : "some imports",
            "code" : [
                "import numpy as np",
                "import matplotlib as mpl",
                "print('spam')"
            ]
        }
    ]
}

You may need to restart your notebook for the changes to take effect.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4