{"componentChunkName":"component---node-modules-smooth-doc-src-templates-doc-js","path":"/docs/class/","result":{"data":{"mdx":{"fields":{"pageType":"doc","title":"Classes","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\": \"Classes\",\n  \"section\": \"Quick Docs\",\n  \"order\": 3\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, \"Classes are used to create objects that have specific behavior.\"), mdx(\"p\", null, \"Every object in Python has a class, including \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"list\"), \"s, \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"dict\"), \"ionaries and even numbers. Using a class to group code and data like this is the foundation of Object Oriented Programming. Classes allow you to expose a simple, consistent interface while hiding the more complicated details. This simplifies the rest of your program and makes it easier to separately maintain and debug each component.\"), mdx(\"p\", null, \"Here is an example class:\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-python\"\n  }, \"class Foo:\\n    def __init__(self, somedata):\\n        self.my_attrib = somedata\\n\\n    def show(self):\\n        print(self.my_attrib)\\n\")), mdx(\"p\", null, \"To use a class, you need to instantiate it. The following creates a new object named \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"bar\"), \", with \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"Foo\"), \" as its class.\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-python\"\n  }, \"bar = Foo('data')\\nbar.show()\\n\")), mdx(\"p\", null, \"We can access any of \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"Foo\"), \"'s methods via \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"bar.my_method()\"), \", and access any of \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"bar\"), \"s data via \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"bar.my_attribute\"), \".\"));\n}\n;\nMDXContent.isMDXComponent = true;","tableOfContents":{}}},"pageContext":{"id":"f473401c-055a-5a00-a28d-c30f2212e675"}},"staticQueryHashes":["1022386572","1122327541","1339625561","2140385554","3442269102","3597609067"]}