{"id":405,"date":"2020-04-14T18:08:47","date_gmt":"2020-04-14T09:08:47","guid":{"rendered":"http:\/\/batmask.dothome.co.kr\/?p=405"},"modified":"2025-09-11T18:42:48","modified_gmt":"2025-09-11T09:42:48","slug":"python-access-modifier-%ea%b7%b8%eb%a6%ac%ea%b3%a0-%ec%b0%b8%ea%b3%a0%ec%9a%a9-%eb%a7%81%ed%81%ac","status":"publish","type":"post","link":"http:\/\/batmask.net\/index.php\/2020\/04\/14\/405\/","title":{"rendered":"Python : Access Modifier \uadf8\ub9ac\uace0 \ucc38\uace0\uc6a9 \ub9c1\ud06c"},"content":{"rendered":"\n<p>\uc55e\uc11c, Python\uc5d0\uc11c OOP \ud504\ub85c\uadf8\ub798\ubc0d\uc744 \ud558\uba70 \uacc4\uc18d \ubcbd\uc5d0 \ubd80\ub52a\ud78c\ub2e4\uace0 \uc598\uae38 \ud588\uc5c8\ub2e4. \uadf8 \uc911 \ud558\ub098\uac00 access modifier\uc778 public, protected, private\uc774 Python\uc5d0 \uc5c6\ub294 \uc810\uc774\ub2e4. <\/p>\n\n\n\n<p>\ud574\ub2f9 modifier\ub4e4\uc740 \uc5c6\uc9c0\ub9cc, \uc720\uc0ac\ud55c naming convention\uc744 \uc81c\uacf5\ud55c\ub2e4. \uc774\ub984 \uc55e\uc5d0 &#8216;_'(underscore) \ub610\ub294 &#8216;__'(double underscore)\ub97c \ubd99\uc5ec\uc8fc\uba74 \ub41c\ub2e4.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-Roboto-Mono.ttf\" style=\"font-size:clamp(14px, .875rem, 21px);font-family:Code-Pro-Roboto-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#adbac7;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:clamp(20px, 1.25rem, 30px);--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#22272e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#adbac7;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>class BContactDB:\n\n    def __init__(self):\n        super().__init__()\n        self.__db_name: str = \"test.db\"\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark-dimmed\" style=\"background-color: #22272e\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F47067\">class<\/span><span style=\"color: #ADBAC7\"> <\/span><span style=\"color: #F69D50\">BContactDB<\/span><span style=\"color: #ADBAC7\">:<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">    <\/span><span style=\"color: #F47067\">def<\/span><span style=\"color: #ADBAC7\"> <\/span><span style=\"color: #6CB6FF\">__init__<\/span><span style=\"color: #ADBAC7\">(self):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">        <\/span><span style=\"color: #6CB6FF\">super<\/span><span style=\"color: #ADBAC7\">().<\/span><span style=\"color: #6CB6FF\">__init__<\/span><span style=\"color: #ADBAC7\">()<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">        <\/span><span style=\"color: #6CB6FF\">self<\/span><span style=\"color: #ADBAC7\">.__db_name: <\/span><span style=\"color: #6CB6FF\">str<\/span><span style=\"color: #ADBAC7\"> <\/span><span style=\"color: #F47067\">=<\/span><span style=\"color: #ADBAC7\"> <\/span><span style=\"color: #96D0FF\">&quot;test.db&quot;<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p>db_name\uc5d0 &#8216;__&#8217;\ub85c \uc2dc\uc791\ud558\ub3c4\ub85d \uc774\ub984\uc744 \uc0ac\uc6a9\ud588\uace0, \uc774 \uac12\uc744 \ud074\ub798\uc2a4 \uc678\ubd80\uc5d0\uc11c \uc5d1\uc138\uc2a4\ud558\uba74 attribute error\uac00 \ubc1c\uc0dd\ud558\uac8c \ub41c\ub2e4. &#8216;_'(underscore) \ud558\ub098\ub97c \uc0ac\uc6a9\ud558\uba74, private, \ub450\uac1c\ub97c \uc0ac\uc6a9\ud558\uba74 protected\ucc98\ub7fc \uc0ac\uc6a9\ud560 \uc218 \uc788\ub2e4.<\/p>\n\n\n\n<p>\ud074\ub798\uc2a4\uc5d0 \ub300\ud574\uc11c\ub3c4, \ubaa8\ub4c8\uc548\uc5d0\uc11c\ub9cc \uc0ac\uc6a9\ud558\uace0 \uc2f6\uc744 \ub54c\uac00 \uc788\ub2e4. \uc5ed\uc2dc \ud074\ub798\uc2a4 \uc774\ub984\uc55e\uc5d0 &#8216;_'(underscore)\ub97c \ubd99\uc5ec\uc900\ub2e4.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-Roboto-Mono.ttf\" style=\"font-size:clamp(14px, .875rem, 21px);font-family:Code-Pro-Roboto-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#adbac7;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:clamp(20px, 1.25rem, 30px);--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#22272e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#adbac7;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>class _QueryType(Enum):\n    SELECT = 1\n    DELETE = 2<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark-dimmed\" style=\"background-color: #22272e\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F47067\">class<\/span><span style=\"color: #ADBAC7\"> <\/span><span style=\"color: #F69D50\">_QueryType<\/span><span style=\"color: #ADBAC7\">(<\/span><span style=\"color: #6CB6FF\">Enum<\/span><span style=\"color: #ADBAC7\">):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">    <\/span><span style=\"color: #6CB6FF\">SELECT<\/span><span style=\"color: #ADBAC7\"> <\/span><span style=\"color: #F47067\">=<\/span><span style=\"color: #ADBAC7\"> <\/span><span style=\"color: #6CB6FF\">1<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ADBAC7\">    <\/span><span style=\"color: #6CB6FF\">DELETE<\/span><span style=\"color: #ADBAC7\"> <\/span><span style=\"color: #F47067\">=<\/span><span style=\"color: #ADBAC7\"> <\/span><span style=\"color: #6CB6FF\">2<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>\uc774\ub807\uac8c\ud558\uba74, \uc678\ubd80\uc5d0\uc11c import\uc2dc \uc774\ub984\uc774 \ub098\ud0c0\ub098\uc9c0 \uc54a\ub294\ub2e4.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity is-style-dots\"\/>\n\n\n\n<p>Python\uc5d0\uc11c OOP Programming\uc744 \ud558\ub294\uac8c \uc0c1\ub2f9\ud788 \uc0dd\uc18c\ud558\uace0 \uae4c\ub2e4\ub85c\uc6cc\uc11c \ub530\ub85c \uc815\ub9ac\ub97c \ud558\uace0\uc2f6\uc5c8\ub2e4. \uadf8\ub7f0\ub370, \uae30\ubcf8\uc801\uc778 \ub0b4\uc6a9\ub4e4\uc744 \uae54\ub054\ud558\uac8c \uc815\ub9ac\ud55c \uc0ac\uc774\ud2b8\uac00 \uc788\uc5b4 \uc18c\uac1c\ud55c\ub2e4.<\/p>\n\n\n\n<p><a href=\"https:\/\/stackabuse.com\/object-oriented-programming-in-python\/\">https:\/\/stackabuse.com\/object-oriented-programming-in-python\/<\/a><\/p>\n\n\n\n<p>\uae30\ubcf8\uc801\uc778 OOP \uac1c\ub150\ub4e4\uc5d0 \ud574\ub2f9\ud558\ub294 Python \ub0b4\uc6a9\ub4e4\uc744 \uc124\uba85\ud558\uace0 \uc788\ub2e4. \uc774 \uae00\uc744 \uc9c4\uc791\uc5d0 \ubd24\uc73c\uba74 \uc870\uae08\uc740 \uace0\uc0dd\uc744 \ub35c\ud588\uc744\uac70 \uac19\ub124.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\uc55e\uc11c, Python\uc5d0\uc11c OOP \ud504\ub85c\uadf8\ub798\ubc0d\uc744 \ud558\uba70 \uacc4\uc18d \ubcbd\uc5d0 \ubd80\ub52a\ud78c\ub2e4\uace0 \uc598\uae38 \ud588\uc5c8\ub2e4. \uadf8 \uc911 \ud558\ub098\uac00 access modifier\uc778 public, protected, private\uc774 Python\uc5d0 \uc5c6\ub294 \uc810\uc774\ub2e4. \ud574\ub2f9 modifier\ub4e4\uc740 \uc5c6\uc9c0\ub9cc, \uc720\uc0ac\ud55c naming convention\uc744 \uc81c\uacf5\ud55c\ub2e4. \uc774\ub984 \uc55e\uc5d0 &#8216;_'(underscore) \ub610\ub294 &#8216;__'(double underscore)\ub97c \ubd99\uc5ec\uc8fc\uba74 \ub41c\ub2e4. db_name\uc5d0 &#8216;__&#8217;\ub85c \uc2dc\uc791\ud558\ub3c4\ub85d \uc774\ub984\uc744 \uc0ac\uc6a9\ud588\uace0, \uc774 \uac12\uc744 \ud074\ub798\uc2a4 \uc678\ubd80\uc5d0\uc11c \uc5d1\uc138\uc2a4\ud558\uba74 attribute error\uac00 \ubc1c\uc0dd\ud558\uac8c \ub41c\ub2e4. &#8216;_'(underscore) \ud558\ub098\ub97c \uc0ac\uc6a9\ud558\uba74, private, \ub450\uac1c\ub97c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33],"tags":[123,116,35,55],"class_list":["post-405","post","type-post","status-publish","format-standard","hentry","category-python","tag-access-modifier","tag-oop","tag-python","tag-python-kr"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"http:\/\/batmask.net\/index.php\/wp-json\/wp\/v2\/posts\/405","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/batmask.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/batmask.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/batmask.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/batmask.net\/index.php\/wp-json\/wp\/v2\/comments?post=405"}],"version-history":[{"count":2,"href":"http:\/\/batmask.net\/index.php\/wp-json\/wp\/v2\/posts\/405\/revisions"}],"predecessor-version":[{"id":3454,"href":"http:\/\/batmask.net\/index.php\/wp-json\/wp\/v2\/posts\/405\/revisions\/3454"}],"wp:attachment":[{"href":"http:\/\/batmask.net\/index.php\/wp-json\/wp\/v2\/media?parent=405"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/batmask.net\/index.php\/wp-json\/wp\/v2\/categories?post=405"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/batmask.net\/index.php\/wp-json\/wp\/v2\/tags?post=405"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}