{"id":16341,"date":"2024-01-06T13:47:00","date_gmt":"2024-01-06T04:47:00","guid":{"rendered":"http:\/\/www.tyosuke20xx.com\/blog\/?p=16341"},"modified":"2024-01-06T13:47:02","modified_gmt":"2024-01-06T04:47:02","slug":"python-setter%ef%bd%a4getter","status":"publish","type":"post","link":"http:\/\/www.tyosuke20xx.com\/blog\/?p=16341","title":{"rendered":"python setter\uff64getter"},"content":{"rendered":"\n<p>class Post:<br>def <strong>init<\/strong>(self, text):<br>self._text = text<br>self._likes = 0<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>def show(self):\n    print(f\"{self._text} - {self._likes}\")\n\ndef like(self):\n    self._likes += 1\n\ndef set_likes(self, num):\n    self._likes = num\n\ndef get_likes(self):\n    return self._likes<\/code><\/pre>\n\n\n\n<p>posts = [<br>Post(&#8220;Hello&#8221;),<br>Post(&#8220;Hi&#8221;),<br>]<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">posts[0]._likes = 100<\/h1>\n\n\n\n<h1 class=\"wp-block-heading\">print(posts[0]._likes)<\/h1>\n\n\n\n<p>posts[0].set_likes(100)<br>print(posts[0].get_likes())<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">for post in posts:<\/h1>\n\n\n\n<h1 class=\"wp-block-heading\">post.show()<\/h1>\n","protected":false},"excerpt":{"rendered":"<p>class Post:def init(self, text):self._text = textself._likes = 0 posts = [Post(&#8220;Hello&#8221;),Post(&#038;#822 &hellip; <a href=\"http:\/\/www.tyosuke20xx.com\/blog\/?p=16341\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;python setter\uff64getter&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[4,65],"tags":[3,39],"class_list":["post-16341","post","type-post","status-publish","format-standard","hentry","category-programming","category-python","tag-programming","tag-python"],"aioseo_notices":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/16341","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=16341"}],"version-history":[{"count":1,"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/16341\/revisions"}],"predecessor-version":[{"id":16342,"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/16341\/revisions\/16342"}],"wp:attachment":[{"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=16341"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=16341"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=16341"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}