{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {
    "Notes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Warns": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Raises": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Yields": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Methods": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Returns": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Hooks for IPython."
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Receives": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Warnings": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Attributes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Parameters": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Extended Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "In Python, it is possible to overwrite any method of any object if you really want to.  But IPython exposes a few 'hooks', methods which are "
            },
            {
              "__type": "Emphasis",
              "__tag": 4047,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "designed"
                }
              ]
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " to be overwritten by users for customization purposes.  This module defines the default versions of all such hooks, which get used by IPython if not overridden by the user."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Hooks are simple functions, but they should be declared with "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "self"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " as their first argument, because when activated they are registered into IPython as instance methods. The self argument will be the IPython running instance itself, so hooks have full access to the entire IPython object."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "If you wish to define a new hook and activate it, you can make an "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "extension",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "docs",
                "path": "/config/extensions/index"
              },
              "kind": "docs"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " or a "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "startup script <startup_files>",
              "domain": null,
              "role": "ref",
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". For example, you could use a startup file like this      "
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "import os\n\ndef calljed(self,filename, linenum):\n    \"My editor hook calls the jed editor directly.\"\n    print(\"Calling my own editor, jed ...\")\n    if os.system('jed +%d %s' % (linenum,filename)) != 0:\n        raise TryNext()\n\ndef load_ipython_extension(ip):\n    ip.set_hook('editor', calljed)",
          "execution_status": null,
          "out": ""
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Other Parameters": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    }
  },
  "_ordered_sections": [
    "Summary",
    "Extended Summary",
    "Parameters",
    "Attributes",
    "Methods",
    "Returns",
    "Yields",
    "Receives",
    "Other Parameters",
    "Raises",
    "Warns",
    "Warnings",
    "Notes"
  ],
  "item_file": "/IPython/core/hooks.py",
  "item_line": 0,
  "item_type": "module",
  "aliases": [
    "IPython.core.hooks"
  ],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [],
  "signature": null,
  "references": null,
  "qa": "IPython.core.hooks",
  "arbitrary": [
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Hooks for IPython."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "In Python, it is possible to overwrite any method of any object if you really want to.  But IPython exposes a few 'hooks', methods which are "
            },
            {
              "__type": "Emphasis",
              "__tag": 4047,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "designed"
                }
              ]
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " to be overwritten by users for customization purposes.  This module defines the default versions of all such hooks, which get used by IPython if not overridden by the user."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Hooks are simple functions, but they should be declared with "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "self"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " as their first argument, because when activated they are registered into IPython as instance methods. The self argument will be the IPython running instance itself, so hooks have full access to the entire IPython object."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "If you wish to define a new hook and activate it, you can make an "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "extension",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "docs",
                "path": "/config/extensions/index"
              },
              "kind": "docs"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " or a "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "startup script <startup_files>",
              "domain": null,
              "role": "ref",
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". For example, you could use a startup file like this      "
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "import os\n\ndef calljed(self,filename, linenum):\n    \"My editor hook calls the jed editor directly.\"\n    print(\"Calling my own editor, jed ...\")\n    if os.system('jed +%d %s' % (linenum,filename)) != 0:\n        raise TryNext()\n\ndef load_ipython_extension(ip):\n    ip.set_hook('editor', calljed)",
          "execution_status": null,
          "out": ""
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    }
  ],
  "local_refs": []
}