{"id":81,"date":"2015-08-07T01:40:29","date_gmt":"2015-08-06T16:40:29","guid":{"rendered":"http:\/\/boltech21.net\/blog\/vottie\/?p=81"},"modified":"2015-09-09T01:23:32","modified_gmt":"2015-09-08T16:23:32","slug":"python-oop","status":"publish","type":"post","link":"https:\/\/boltech21.net\/blog\/vottie\/?p=81","title":{"rendered":"python\u305d\u306e2"},"content":{"rendered":"<p>def add(x,y)\u306f\u30c0\u30e1\u3002\u4ee5\u4e0b\u306e\u30a8\u30e9\u30fc\u304c\u3002\u3002\u3002<br \/>\ntypeError: add() takes exactly 2 arguments (3 given)<\/p>\n<p>def add(self, x, y)\u306a\u3089\u30aa\u30c3\u30b1\u30fc\u3002self\u304c\u5fc5\u9808\u306a\u306e\u304b?!\u30cd\u30c3\u30c8\u3067\u8abf\u3079\u308b\u3068\u3001\u78ba\u304b\u306b\u305d\u3093\u306a\u3053\u3068\u66f8\u3044\u3066\u3042\u308b\u3002\u305d\u3057\u3066\u4ed6\u8a00\u8a9e\u304b\u3089\u6765\u305f\u4eba\u306b\u306f\u30ad\u30e2\u3044\u3068\u3082\u66f8\u304b\u308c\u3066\u3044\u308b\u2026<\/p>\n<p><a href=\"https:\/\/github.com\/vottie\/lang\/blob\/master\/python\/calc\/calc.py\" target=\"_blank\">calc.py<\/a><\/p>\n<p>\u30cd\u30c3\u30c8\u3067\u4f8b\u3092\u898b\u3066\u305f\u3089\u3001self\u3092\u66f8\u3044\u3066\u3044\u306a\u3044\u306e\u3082\u3042\u308b\u3002\u3069\u3063\u3061\u304c\u672c\u5f53\uff1f\u3068\u601d\u3063\u3066\u8a66\u3057\u3066\u305f\u3089class\u306e\u30e1\u30bd\u30c3\u30c9\u306fself\u304c\u5fc5\u8981\u3060\u3051\u3069\u3001\u305f\u3060\u306e\u30e1\u30bd\u30c3\u30c9\u306a\u3089\u8981\u3089\u306a\u3044\u307f\u305f\u3044\u3067\u3001\u4ee5\u4e0b\u306f\u30aa\u30c3\u30b1\u30fc\u3060\u3063\u305f\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\ndef add(x, y):\r\n    return x + y\r\n\r\n\r\nresult = add(100,200)\r\nprint result\r\n<\/pre>\n<p>\u5225\u306e\u30d5\u30a1\u30a4\u30eb\u304b\u3089\u30af\u30e9\u30b9\u3092new\u3057\u3066\u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3073\u51fa\u3059\u3068\u3044\u3046\u306e\u3082\u3084\u3063\u3066\u307f\u305f\u3002from \u30d5\u30a1\u30a4\u30eb\u540d import \u30af\u30e9\u30b9\u540d\u3068\u66f8\u304f\u3089\u3057\u3044\u3002unit test\u306f\u307e\u305f\u4eca\u5ea6\u3002<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>def add(x,y)\u306f\u30c0\u30e1\u3002\u4ee5\u4e0b\u306e\u30a8\u30e9\u30fc\u304c\u3002\u3002\u3002 typeError: add() takes exactly 2 arguments (3 given) def add(self, x, y)\u306a\u3089\u30aa\u30c3\u30b1\u30fc\u3002self\u304c\u5fc5\u9808\u306a\u306e\u304b?!\u30cd\u30c3\u30c8\u3067\u8abf\u3079\u308b\u3068\u3001\u78ba\u304b\u306b\u305d\u3093\u306a\u3053\u3068\u66f8\u3044\u3066\u3042\u308b\u3002\u305d\u3057\u3066\u4ed6\u8a00\u8a9e\u304b\u3089\u6765\u305f\u4eba\u306b\u306f\u30ad\u30e2\u3044\u3068\u3082\u66f8\u304b\u308c\u3066\u3044\u308b\u2026 calc.py \u30cd\u30c3\u30c8\u3067\u4f8b\u3092\u898b\u3066\u305f\u3089\u3001self\u3092\u66f8\u3044\u3066\u3044\u306a\u3044\u306e\u3082\u3042\u308b\u3002\u3069\u3063\u3061\u304c\u672c\u5f53\uff1f\u3068\u601d\u3063\u3066\u8a66\u3057\u3066\u305f\u3089class\u306e\u30e1\u30bd\u30c3\u30c9\u306fself\u304c\u5fc5\u8981\u3060\u3051\u3069\u3001\u305f\u3060\u306e\u30e1\u30bd\u30c3\u30c9\u306a\u3089\u8981\u3089\u306a\u3044\u307f\u305f\u3044\u3067\u3001\u4ee5\u4e0b\u306f\u30aa\u30c3\u30b1\u30fc\u3060\u3063\u305f\u3002 def add(x, y): return x + y result = add(100,200) print result \u5225\u306e\u30d5\u30a1\u30a4\u30eb\u304b\u3089\u30af\u30e9\u30b9\u3092new\u3057\u3066\u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3073\u51fa\u3059\u3068\u3044\u3046\u306e\u3082\u3084\u3063\u3066\u307f\u305f\u3002from \u30d5\u30a1\u30a4\u30eb\u540d import \u30af\u30e9\u30b9\u540d\u3068\u66f8\u304f\u3089\u3057\u3044\u3002unit test\u306f\u307e\u305f\u4eca\u5ea6\u3002 &nbsp;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[6],"tags":[8],"class_list":["post-81","post","type-post","status-publish","format-standard","hentry","category-computer","tag-python"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p4Yc9l-1j","_links":{"self":[{"href":"https:\/\/boltech21.net\/blog\/vottie\/index.php?rest_route=\/wp\/v2\/posts\/81","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/boltech21.net\/blog\/vottie\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/boltech21.net\/blog\/vottie\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/boltech21.net\/blog\/vottie\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/boltech21.net\/blog\/vottie\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=81"}],"version-history":[{"count":8,"href":"https:\/\/boltech21.net\/blog\/vottie\/index.php?rest_route=\/wp\/v2\/posts\/81\/revisions"}],"predecessor-version":[{"id":96,"href":"https:\/\/boltech21.net\/blog\/vottie\/index.php?rest_route=\/wp\/v2\/posts\/81\/revisions\/96"}],"wp:attachment":[{"href":"https:\/\/boltech21.net\/blog\/vottie\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=81"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/boltech21.net\/blog\/vottie\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=81"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/boltech21.net\/blog\/vottie\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=81"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}