{"id":9956,"date":"2022-12-23T23:32:29","date_gmt":"2022-12-23T14:32:29","guid":{"rendered":"https:\/\/pandanote.info\/?p=9956"},"modified":"2022-12-23T23:34:54","modified_gmt":"2022-12-23T14:34:54","slug":"python3%e3%81%aeclassmethod%e3%83%87%e3%82%b3%e3%83%ac%e3%83%bc%e3%82%bf%e3%82%92%e4%bd%bf%e3%81%86%e3%81%a8%e3%82%b3%e3%83%b3%e3%82%b9%e3%83%88%e3%83%a9%e3%82%af%e3%82%bf%e3%81%ae%e3%82%aa%e3%83%bc","status":"publish","type":"post","link":"https:\/\/pandanote.info\/?p=9956","title":{"rendered":"Python3\u306eclassmethod\u30c7\u30b3\u30ec\u30fc\u30bf\u3092\u4f7f\u3046\u3068\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u306e\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u306e\u3088\u3046\u306a\u3053\u3068\u304c\u3067\u304d\u308b\u3068\u805e\u3044\u305f\u306e\u3067\u3001\u8a66\u3057\u3066\u307f\u305f\u3002"},"content":{"rendered":"<h2>\u306f\u3058\u3081\u306b<\/h2>\n<p>Java\u7cfb\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u9577\u3044\u671f\u9593\u306b\u308f\u305f\u3063\u3066\u66f8\u3044\u305f\u5f8c\u3001Java\u7cfb\u3067\u306a\u3044\u4ed6\u306e\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9e\u3067\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u66f8\u304d\u59cb\u3081\u3066\u3061\u3087\u3063\u3068\u3057\u305f\u96e3\u554f\u306b\u51fa\u304f\u308f\u3059\u3068\u3001\u3064\u3044Java\u7cfb\u3067\u306f\u7c21\u5358\u306b\u3067\u304d\u3066\u3044\u305f\u306f\u305a\u306e\u66f8\u304d\u65b9\u3092\u8a66\u3057\u3066\u307f\u305f\u304f\u306a\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u305d\u3093\u306a\u4e2d\u3001Python3\u3067\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u3092\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u3057\u306a\u3044\u3068\u56f0\u3063\u305f\u3053\u3068\u306b\u306a\u308a\u305d\u3046\u306a\u5c40\u9762\u306b\u906d\u9047\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u5e78\u3044\u306a\u3053\u3068\u306b\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u3092\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u3057\u306a\u304f\u3066\u3082\u3088\u304f\u306a\u308b\u8a2d\u8a08\u306b\u3067\u304d\u308b\u898b\u8fbc\u307f\u3068\u306f\u306a\u308a\u307e\u3057\u305f\u304c\u3001Java\u7cfb\u3067\u306f\u7c21\u5358\u306b\u3067\u304d\u3066\u3044\u305f\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u3092\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u304cPython3\u3067\u3082\u3067\u304d\u308b\u304b\u3082\u3057\u308c\u306a\u3044\u3068\u3044\u3046\u70b9\u306b\u3064\u3044\u3066\u306f\u3061\u3087\u3063\u3068\u8208\u5473\u304c\u6e67\u3044\u305f\u306e\u3067\u3001Python3\u3067\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u306e\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u306e\u3088\u3046\u306a\u30b3\u30fc\u30c9\u3092\u66f8\u304f\u305f\u3081\u306e\u65b9\u6cd5\u306b\u3064\u3044\u3066\u8abf\u3079\u3066\u307f\u3066\u3001\u53ef\u80fd\u305d\u3046\u3067\u3042\u308c\u3070\u8a66\u3057\u3066\u307f\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n<h2>\u3044\u304d\u306a\u308a\u30b3\u30fc\u30c9\u4f8b<\/h2>\n<p>\u5c11\u3057\u8abf\u3079\u3066\u307f\u308b\u3068\u3001Python3\u306b\u306f\u300cclassmethod\u30c7\u30b3\u30ec\u30fc\u30bf\u300d\u306a\u308b\u3082\u306e\u304c\u3042\u308b\u3053\u3068\u304c\u308f\u304b\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>Python3\u3067\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u306e\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u306e\u3088\u3046\u306a\u30b3\u30fc\u30c9\u3092\u66f8\u304f\u3053\u3068\u304c\u3067\u304d\u305d\u3046\u3067\u3059\u3002<\/p>\n<p>\u305d\u3053\u3067\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30d7\u30ed\u30b0\u30e9\u30e0(\u3068\u3044\u3046\u304b\u30af\u30e9\u30b9\u306e\u5b9a\u7fa9)\u3092\u66f8\u3044\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p><script src=\"https:\/\/gist.github.com\/pandanote-info\/b5a63374d118bbfd5513f115d846acc4.js\"><\/script><\/p>\n<p>Expense\u30af\u30e9\u30b9\u3067\u3059\u3002<\/p>\n<p>Expense\u30af\u30e9\u30b9\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306f1\u56de\u306e\u8cbb\u7528\u3092\u8868\u3057\u3066\u3044\u3066\u3001\u652f\u51fa\u306f\u3001<\/p>\n<ul>\n<li>\u91d1\u984d(amount)<\/li>\n<li>\u76ee\u7684(reason)<\/li>\n<li>\u5099\u8003(remark)<\/li>\n<\/ul>\n<p>\u306e3\u500b\u306e\u9805\u76ee\u304b\u3089\u69cb\u6210\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3053\u306eExpense\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306fPython\u3067\u306f\u4e00\u822c\u7684\u306b\u4f7f\u308f\u308c\u3066\u3044\u308b\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf(__init__, 7-10\u884c\u76ee, 3\u500b\u306e\u5f15\u6570\u3092\u3068\u308b\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u3067\u3059\u3002)\u306e\u4ed6\u306b\u3001classmethod\u30c7\u30b3\u30ec\u30fc\u30bf\u3092\u7528\u3044\u3066\u4ee5\u4e0b\u306e2\u500b\u306e\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf(\u306e\u3088\u3046\u306b\u52d5\u4f5c\u3059\u308b\u30af\u30e9\u30b9\u30e1\u30bd\u30c3\u30c9)\u3092\u5b9a\u7fa9\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<ul>\n<li>no_remark(12-14\u884c\u76ee): amount\u53ca\u3073remark\u306e\u307f\u3092\u5f15\u6570\u3068\u3057\u3066\u3068\u308b\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u3002<\/li>\n<li>copy(16-18\u884c\u76ee): Expense\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u5f15\u6570\u3068\u3057\u3066\u3068\u308b\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf(\u3044\u308f\u3086\u308b\u30b3\u30d4\u30fc\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf)<\/li>\n<\/ul>\n<p>Java\u306e\u4e16\u754c\u3067\u306f\u5148\u982d\u306b&#8221;@&#8221;\u306e\u30bf\u30b0\u306e\u3064\u3044\u305f\u30b3\u30e1\u30f3\u30c8\u306e\u3088\u3046\u306a\u3082\u306e\u306f\u300c\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u300d\u3068\u3044\u3044\u307e\u3059\u304c\u3001Python\u306e\u4e16\u754c\u3067\u306f\u5148\u982d\u306b&#8221;@&#8221;\u306e\u30bf\u30b0\u306e\u3064\u3044\u305f\u30b3\u30e1\u30f3\u30c8\u306e\u3088\u3046\u306a\u3082\u306e\u306f\u300c\u30c7\u30b3\u30ec\u30fc\u30bf\u300d\u3068\u3044\u3046\u3088\u3046\u3067\u3059\u3002<\/p>\n<p>\u7d1b\u3089\u308f\u3057\u3044\u3067\u3059\u306d\u3002<\/p>\n<h2>\u52d5\u4f5c\u78ba\u8a8d<\/h2>\n<p>Python3\u306eCLI\u306b\u524d\u7bc0\u306b\u793a\u3057\u305fExpense\u30af\u30e9\u30b9\u3092import\u3057\u3066\u52d5\u4f5c\u78ba\u8a8d\u3067\u3059\u3002<\/p>\n<h3>__init__<\/h3>\n<p>\u307e\u305a\u306f__init__\u95a2\u6570\u306b\u3064\u3044\u3066\u52d5\u4f5c\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/pandanote.info\/?attachment_id=9957\" rel=\"attachment wp-att-9957\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/pandanote.info\/wordpress\/wp-content\/uploads\/2022\/12\/python_decorator_scene1.png\" alt=\"\" width=\"893\" height=\"194\" class=\"alignnone size-full wp-image-9957\" srcset=\"https:\/\/pandanote.info\/wordpress\/wp-content\/uploads\/2022\/12\/python_decorator_scene1.png 893w, https:\/\/pandanote.info\/wordpress\/wp-content\/uploads\/2022\/12\/python_decorator_scene1-300x65.png 300w, https:\/\/pandanote.info\/wordpress\/wp-content\/uploads\/2022\/12\/python_decorator_scene1-768x167.png 768w, https:\/\/pandanote.info\/wordpress\/wp-content\/uploads\/2022\/12\/python_decorator_scene1-660x143.png 660w\" sizes=\"auto, (max-width: 893px) 100vw, 893px\" \/><\/a><\/p>\n<p>Python3\u306e\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u3068\u3057\u3066\u306e\u6975\u3081\u3066\u4e00\u822c\u7684\u306a\u52d5\u4f5c\u3067\u3059\u3002<\/p>\n<h3>no_remark<\/h3>\n<p>\u4e8c\u3064\u76ee\u306fno_remark\u95a2\u6570\u3067\u3059\u3002<\/p>\n<p>no_remark\u95a2\u6570\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u66f8\u304d\u307e\u3059\u3002<\/p>\n<div class=\"code\">b = Expense.no_remark(4500,&#8221;physics&#8221;)<\/div>\n<p>&nbsp;<\/p>\n<p>\u30af\u30e9\u30b9\u30e1\u30bd\u30c3\u30c9\u306f\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u4f5c\u308b\u3053\u3068\u306a\u304f\u3001\u30af\u30e9\u30b9\u304b\u3089\u76f4\u63a5\u547c\u3073\u51fa\u3059\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u5b9f\u884c\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/pandanote.info\/?attachment_id=9958\" rel=\"attachment wp-att-9958\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/pandanote.info\/wordpress\/wp-content\/uploads\/2022\/12\/python_decorator_scene2.png\" alt=\"\" width=\"894\" height=\"213\" class=\"alignnone size-full wp-image-9958\" srcset=\"https:\/\/pandanote.info\/wordpress\/wp-content\/uploads\/2022\/12\/python_decorator_scene2.png 894w, https:\/\/pandanote.info\/wordpress\/wp-content\/uploads\/2022\/12\/python_decorator_scene2-300x71.png 300w, https:\/\/pandanote.info\/wordpress\/wp-content\/uploads\/2022\/12\/python_decorator_scene2-768x183.png 768w, https:\/\/pandanote.info\/wordpress\/wp-content\/uploads\/2022\/12\/python_decorator_scene2-660x157.png 660w\" sizes=\"auto, (max-width: 894px) 100vw, 894px\" \/><\/a><\/p>\n<p>reason\u306e\u5024\u3092\u6301\u305f\u306a\u3044Expense\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304c\u4f5c\u6210\u3067\u304d\u308b\u3053\u3068\u304c\u78ba\u8a8d\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n<h3>copy<\/h3>\n<p>\u4e09\u3064\u76ee\u306fcopy\u95a2\u6570\u3067\u3059\u3002<\/p>\n<p>copy\u95a2\u6570\u306f\u4ee5\u4e0b\u306e2\u884c\u76ee\u306e\u3088\u3046\u306b\u66f8\u3044\u3066\u5b9f\u884c\u3057\u307e\u3059(1\u884c\u76ee\u306f\u30b3\u30d4\u30fc\u5143\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u4f5c\u6210\u3059\u308b\u30b3\u30fc\u30c9\u3067\u3059)\u3002<\/p>\n<div class=\"code\">c = Expense(6000,&#8221;ebook&#8221;,&#8221;electronics&#8221;)<br \/>\ncc = Expense.copy(c)<\/div>\n<p>&nbsp;<\/p>\n<p>\u5b9f\u884c\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/pandanote.info\/?attachment_id=9959\" rel=\"attachment wp-att-9959\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/pandanote.info\/wordpress\/wp-content\/uploads\/2022\/12\/python_decorator_scene3.png\" alt=\"\" width=\"890\" height=\"287\" class=\"alignnone size-full wp-image-9959\" srcset=\"https:\/\/pandanote.info\/wordpress\/wp-content\/uploads\/2022\/12\/python_decorator_scene3.png 890w, https:\/\/pandanote.info\/wordpress\/wp-content\/uploads\/2022\/12\/python_decorator_scene3-300x97.png 300w, https:\/\/pandanote.info\/wordpress\/wp-content\/uploads\/2022\/12\/python_decorator_scene3-768x248.png 768w, https:\/\/pandanote.info\/wordpress\/wp-content\/uploads\/2022\/12\/python_decorator_scene3-660x213.png 660w\" sizes=\"auto, (max-width: 890px) 100vw, 890px\" \/><\/a><\/p>\n<p>\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9cc(\u30b3\u30d4\u30fc\u5148)\u304c\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9c(\u30b3\u30d4\u30fc\u5143)\u3092\u30b3\u30d4\u30fc\u3059\u308b\u3053\u3068\u306b\u3088\u308a\u751f\u6210\u3055\u308c\u305f\u3053\u3068\u3092\u78ba\u8a8d\u5f8c\u3001c\u306eremark\u3092&#8221;informatics&#8221;\u306b\u5909\u66f4\u3057\u305f\u5f8c\u3082cc\u306eremark\u304c&#8221;electronics&#8221;\u306e\u307e\u307e\u3067\u5909\u5316\u3057\u3066\u3044\u306a\u3044\u3053\u3068\u3092\u78ba\u8a8d\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3053\u3053\u307e\u3067\u306e\u78ba\u8a8d\u7d50\u679c\u3088\u308a\u3001copy\u95a2\u6570\u304c\u6df1\u3044\u30b3\u30d4\u30fc(deepcopy)\u3092\u884c\u3046\u3053\u3068\u304c\u3067\u304d\u308b\u95a2\u6570\u3067\u3042\u308b\u3053\u3068\u304c\u308f\u304b\u308a\u307e\u3059\u3002<\/p>\n<h2>\u307e\u3068\u3081<\/h2>\n<p>\u3053\u3053\u307e\u3067\u306e\u5b9f\u9a13\u3067\u3001\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u3092\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u3059\u308b\u5834\u5408\u306b\u306f\u30af\u30e9\u30b9\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u7528\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u3053\u3068\u304c\u308f\u304b\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>\u307e\u305f\u3001\u30af\u30e9\u30b9\u30e1\u30bd\u30c3\u30c9\u3068\u3059\u308b\u304b\u3089\u306b\u306f\u3001\u30e1\u30bd\u30c3\u30c9\u540d\u306b\u3064\u3044\u3066\u306f\u76f8\u7570\u306a\u308b\u3082\u306e\u3092\u5b9a\u7fa9\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u305d\u306e\u4e00\u65b9\u3067\u3001\u30af\u30e9\u30b9\u30e1\u30bd\u30c3\u30c9\u306e\u547d\u540d\u3084\u904b\u7528\u306e\u65b9\u91dd\u3092\u3046\u307e\u304f\u6c7a\u3081\u3066\u3084\u308b\u3068\u9762\u767d\u3044\u4f7f\u3044\u65b9\u3092\u7de8\u307f\u51fa\u3059\u3053\u3068\u304c\u3067\u304d\u308b\u306e\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002<\/p>\n<p>\u3053\u306e\u8a18\u4e8b\u306f\u4ee5\u4e0a\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u306f\u3058\u3081\u306b Java\u7cfb\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u9577\u3044\u671f\u9593\u306b\u308f\u305f\u3063\u3066\u66f8\u3044\u305f\u5f8c\u3001Java\u7cfb\u3067\u306a\u3044\u4ed6\u306e\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9e\u3067\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u66f8\u304d\u59cb\u3081\u3066\u3061\u3087\u3063\u3068\u3057\u305f\u96e3\u554f\u306b\u51fa\u304f\u308f\u3059\u3068\u3001\u3064\u3044Java\u7cfb\u3067\u306f\u7c21\u5358\u306b\u3067\u304d\u3066\u3044\u305f\u306f\u305a\u306e\u66f8\u304d\u65b9\u3092\u8a66\u3057\u3066\u307f\u305f\u304f\u306a\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002 \u305d\u3093\u306a\u4e2d\u3001Python3\u3067\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u3092\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u3057\u306a\u3044\u3068\u56f0\u3063\u305f\u3053\u3068\u306b\u306a\u308a\u305d\u3046\u306a\u5c40\u9762\u306b\u906d\u9047\u3057\u307e\u3057\u305f\u3002 \u5e78\u3044\u306a\u3053\u3068\u306b\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u3092\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u3057\u306a\u304f\u3066\u3082\u3088\u304f\u2026 <span class=\"read-more\"><a href=\"https:\/\/pandanote.info\/?p=9956\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":9959,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[],"class_list":["post-9956","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python3"],"_links":{"self":[{"href":"https:\/\/pandanote.info\/index.php?rest_route=\/wp\/v2\/posts\/9956","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pandanote.info\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pandanote.info\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pandanote.info\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pandanote.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=9956"}],"version-history":[{"count":3,"href":"https:\/\/pandanote.info\/index.php?rest_route=\/wp\/v2\/posts\/9956\/revisions"}],"predecessor-version":[{"id":9962,"href":"https:\/\/pandanote.info\/index.php?rest_route=\/wp\/v2\/posts\/9956\/revisions\/9962"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/pandanote.info\/index.php?rest_route=\/wp\/v2\/media\/9959"}],"wp:attachment":[{"href":"https:\/\/pandanote.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=9956"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pandanote.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=9956"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pandanote.info\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=9956"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}