{
  "__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": "This is a method decorator that allows both an instance method and a "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "classmethod",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " to share the same name."
            }
          ]
        }
      ],
      "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": "When using "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "sharedmethod",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "module",
                "path": "astropy.utils.decorators:sharedmethod"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " on a method defined in a class's body, it may be called on an instance, or on a class.  In the former case it behaves like a normal instance method (a reference to the instance is automatically passed as the first "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "self"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " argument of the method)      "
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": ">>> class Example:\n...     @sharedmethod\n...     def identify(self, *args):\n...         print('self was', self)\n...         print('additional args were', args)\n...\n>>> ex = Example()\n>>> ex.identify(1, 2)\nself was <astropy.utils.decorators.Example object at 0x...>\nadditional args were (1, 2)",
          "execution_status": null,
          "out": ""
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "In the latter case, when the "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "sharedmethod",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "module",
                "path": "astropy.utils.decorators:sharedmethod"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is called directly from a class, it behaves like a "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "classmethod",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ":      "
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": ">>> Example.identify(3, 4)\nself was <class 'astropy.utils.decorators.Example'>\nadditional args were (3, 4)",
          "execution_status": null,
          "out": ""
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "This also supports a more advanced usage, where the "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "classmethod",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " implementation can be written separately.  If the class' "
            },
            {
              "__type": "Emphasis",
              "__tag": 4047,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "metaclass"
                }
              ]
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " has a method of the same name as the "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "sharedmethod",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "module",
                "path": "astropy.utils.decorators:sharedmethod"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", the version on the metaclass is delegated to      "
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": ">>> class ExampleMeta(type):\n...     def identify(self):\n...         print('this implements the {0}.identify '\n...               'classmethod'.format(self.__name__))\n...\n>>> class Example(metaclass=ExampleMeta):\n...     @sharedmethod\n...     def identify(self):\n...         print('this implements the instancemethod')\n...\n>>> Example().identify()\nthis implements the instancemethod\n>>> Example.identify()\nthis implements the Example.identify classmethod",
          "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": null,
  "item_line": 876,
  "item_type": "class",
  "aliases": [
    "astropy.utils.sharedmethod"
  ],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [],
  "signature": {
    "__type": "SignatureNode",
    "__tag": 4029,
    "kind": "function",
    "parameters": [
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "function",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_ONLY",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      }
    ],
    "return_annotation": {
      "__type": "Empty",
      "__tag": 4031
    },
    "target_name": "sharedmethod"
  },
  "references": null,
  "qa": "astropy.utils.decorators:sharedmethod",
  "arbitrary": [],
  "local_refs": []
}