{"id":16352,"date":"2024-01-06T15:57:50","date_gmt":"2024-01-06T06:57:50","guid":{"rendered":"http:\/\/www.tyosuke20xx.com\/blog\/?p=16352"},"modified":"2024-01-06T15:57:52","modified_gmt":"2024-01-06T06:57:52","slug":"python-%e3%83%a1%e3%82%bd%e3%83%83%e3%83%89%e3%81%ae%e3%82%aa%e3%83%bc%e3%83%90%e3%83%bc%e3%83%a9%e3%82%a4%e3%83%89","status":"publish","type":"post","link":"http:\/\/www.tyosuke20xx.com\/blog\/?p=16352","title":{"rendered":"python \u30e1\u30bd\u30c3\u30c9\u306e\u30aa\u30fc\u30d0\u30fc\u30e9\u30a4\u30c9"},"content":{"rendered":"\n<p>class Post: # \u89aa\u30af\u30e9\u30b9 Super\u30af\u30e9\u30b9<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<\/code><\/pre>\n\n\n\n<p>class SponsoredPost(Post): # \u5b50\u30af\u30e9\u30b9 Sub\u30af\u30e9\u30b9<br>def <strong>init<\/strong>(self, text, sponsor):<br># self._text = text<br># self._likes = 0<br>super().<strong>init<\/strong>(text)<br>self._sponsor = sponsor<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>def show(self):\n    print(f\"{self._text} - {self._likes} sponsored by {self._sponsor}\")<\/code><\/pre>\n\n\n\n<p>posts = [<br>Post(&#8220;Hello&#8221;),<br>Post(&#8220;Hi&#8221;),<br>SponsoredPost(&#8220;Hey&#8221;, &#8220;dotinstall&#8221;),<br>]<\/p>\n\n\n\n<p>posts[2].like()<\/p>\n\n\n\n<p>for post in posts:<br>post.show()<\/p>\n","protected":false},"excerpt":{"rendered":"<p>class Post: # \u89aa\u30af\u30e9\u30b9 Super\u30af\u30e9\u30b9def init(self, text):self._text = textself._likes = 0 class SponsoredPost(Post): #  &hellip; <a href=\"http:\/\/www.tyosuke20xx.com\/blog\/?p=16352\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;python \u30e1\u30bd\u30c3\u30c9\u306e\u30aa\u30fc\u30d0\u30fc\u30e9\u30a4\u30c9&#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-16352","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\/16352","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=16352"}],"version-history":[{"count":1,"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/16352\/revisions"}],"predecessor-version":[{"id":16353,"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/16352\/revisions\/16353"}],"wp:attachment":[{"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=16352"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=16352"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=16352"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}