{"componentChunkName":"component---node-modules-smooth-doc-src-templates-doc-js","path":"/docs/docstrings/","result":{"data":{"mdx":{"fields":{"pageType":"doc","title":"Docstrings","editLink":""},"body":"var _excluded = [\"components\"];\nfunction _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n/* @jsxRuntime classic */\n/* @jsx mdx */\n\nvar _frontmatter = {\n  \"title\": \"Docstrings\",\n  \"section\": \"Quick Docs\",\n  \"order\": 10\n};\nvar layoutProps = {\n  _frontmatter: _frontmatter\n};\nvar MDXLayout = \"wrapper\";\nreturn function MDXContent(_ref) {\n  var components = _ref.components,\n    props = _objectWithoutProperties(_ref, _excluded);\n  return mdx(MDXLayout, _extends({}, layoutProps, props, {\n    components: components,\n    mdxType: \"MDXLayout\"\n  }), mdx(\"p\", null, \"A \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://docs.python.org/3/glossary.html#term-docstring\"\n  }, mdx(\"inlineCode\", {\n    parentName: \"a\"\n  }, \"docstring\")), \" is a string - always using triple quotes - that's placed at the top of files, classes and functions. A docstring should contain a clear explanation of what it's describing. You can also include descriptions of the subject's parameter(s) and what it returns, as shown below:\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-py\"\n  }, \"def greet(name: str, age: int) -> str:\\n    \\\"\\\"\\\"\\n    Return a string that greets the given person, using their name and age.\\n\\n    :param name: The name of the person to greet.\\n    :param age: The age of the person to greet.\\n\\n    :return: The greeting.\\n    \\\"\\\"\\\"\\n    return f\\\"Hello {name}, you are {age} years old!\\\"\\n\")), mdx(\"p\", null, \"You can get the docstring by using the \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://docs.python.org/3/library/inspect.html#inspect.getdoc\"\n  }, mdx(\"inlineCode\", {\n    parentName: \"a\"\n  }, \"inspect.getdoc\")), \" function, from the built-in \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://docs.python.org/3/library/inspect.html\"\n  }, mdx(\"inlineCode\", {\n    parentName: \"a\"\n  }, \"inspect\")), \" module, or by accessing the \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \".__doc__\"), \" attribute. \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"inspect.getdoc\"), \" is often preferred, as it clears indents from the docstring.\"), mdx(\"p\", null, \"For the last example, you can print it by doing this: \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"print(inspect.getdoc(greet))\"), \".\"), mdx(\"p\", null, \"For more details about what a docstring is and its usage, check out this guide by \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://realpython.com/documenting-python-code/#docstrings-background\"\n  }, \"Real Python\"), \", or the \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://peps.python.org/pep-0257/#what-is-a-docstring\"\n  }, \"official docstring specification\"), \".\"));\n}\n;\nMDXContent.isMDXComponent = true;","tableOfContents":{}}},"pageContext":{"id":"0a64b465-3003-5946-953d-9396dd5a98e8"}},"staticQueryHashes":["1022386572","1122327541","1339625561","2140385554","3442269102","3597609067"]}