Warning: Use of undefined constant memo - assumed 'memo' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/lib.php on line 278
홍차넷
Warning: Use of undefined constant level - assumed 'level' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/outlogin_toby.php on line 34
Warning: Use of undefined constant no - assumed 'no' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/outlogin_toby.php on line 45
Warning: Use of undefined constant r - assumed 'r' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/outlogin_toby.php on line 47
Warning: Use of undefined constant r - assumed 'r' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/outlogin_toby.php on line 51
Warning: Use of undefined constant level - assumed 'level' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/outlogin_toby.php on line 34
Warning: Use of undefined constant no - assumed 'no' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/outlogin_toby.php on line 45
Warning: Use of undefined constant r - assumed 'r' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/outlogin_toby.php on line 47
Warning: Use of undefined constant r - assumed 'r' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/outlogin_toby.php on line 51
Warning: Use of undefined constant is_admin - assumed 'is_admin' (this will throw an Error in a future version of PHP) in /home/redtea/html/zero_header.php on line 269
Warning: Use of undefined constant level - assumed 'level' (this will throw an Error in a future version of PHP) in /home/redtea/html/zero_header.php on line 300
Warning: Use of undefined constant title - assumed 'title' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/bbs_title.php on line 16
질문
Warning: Use of undefined constant no - assumed 'no' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/bbs_title.php on line 21
Warning: Use of undefined constant header - assumed 'header' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/bbs_title.php on line 31
- 질문 게시판입니다.
Warning: Use of undefined constant use_formmail - assumed 'use_formmail' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/lib.php on line 519
Warning: Use of undefined constant use_category - assumed 'use_category' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/include/print_category.php on line 9
전체기타게임진로연애가정/육아체육/스포츠교육의료/건강철학/종교IT/컴퓨터여행과학문화/예술법률홍차넷경제
Warning: Use of undefined constant level - assumed 'level' (this will throw an Error in a future version of PHP) in /home/redtea/html/a_skin/bbsd/setup.php on line 29
Warning: Use of undefined constant no - assumed 'no' (this will throw an Error in a future version of PHP) in /home/redtea/html/a_skin/bbsd/setup.php on line 41
Warning: Use of undefined constant x - assumed 'x' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/view.php on line 398
Warning: Use of undefined constant subject - assumed 'subject' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/view.php on line 402
Warning: Use of undefined constant x - assumed 'x' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/view.php on line 403
Warning: Use of undefined constant reg_date - assumed 'reg_date' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/view.php on line 405
Warning: Use of undefined constant total_comment - assumed 'total_comment' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/view.php on line 406
Warning: Use of undefined constant subject - assumed 'subject' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/view.php on line 402
Warning: Use of undefined constant x - assumed 'x' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/view.php on line 403
Warning: Use of undefined constant reg_date - assumed 'reg_date' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/view.php on line 405
Warning: Use of undefined constant total_comment - assumed 'total_comment' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/view.php on line 406
Warning: Use of undefined constant subject - assumed 'subject' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/view.php on line 402
Warning: Use of undefined constant x - assumed 'x' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/view.php on line 403
Warning: Use of undefined constant subject - assumed 'subject' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/view.php on line 402
Warning: Use of undefined constant x - assumed 'x' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/view.php on line 403
Warning: Use of undefined constant reg_date - assumed 'reg_date' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/view.php on line 405
Warning: Use of undefined constant total_comment - assumed 'total_comment' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/view.php on line 406
Warning: Use of undefined constant subject - assumed 'subject' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/view.php on line 402
Warning: Use of undefined constant x - assumed 'x' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/view.php on line 403
Warning: Use of undefined constant reg_date - assumed 'reg_date' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/view.php on line 405
Warning: Use of undefined constant total_comment - assumed 'total_comment' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/view.php on line 406
Warning: Use of undefined constant subject - assumed 'subject' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/view.php on line 402
Warning: Use of undefined constant x - assumed 'x' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/view.php on line 403
Warning: Use of undefined constant reg_date - assumed 'reg_date' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/view.php on line 405
Warning: Use of undefined constant total_comment - assumed 'total_comment' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/view.php on line 406
Warning: Use of undefined constant name - assumed 'name' (this will throw an Error in a future version of PHP) in /home/redtea/html/a_skin/bbsd/view.php on line 2
Warning: Use of undefined constant HTTP_HOST - assumed 'HTTP_HOST' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/memo_replace.php on line 3
Warning: Use of undefined constant x - assumed 'x' (this will throw an Error in a future version of PHP) in /home/redtea/html/a_skin/bbsd/view.php on line 10
Warning: Use of undefined constant use_category - assumed 'use_category' (this will throw an Error in a future version of PHP) in /home/redtea/html/a_skin/bbsd/view.php on line 40
Date |
Warning: Use of undefined constant reg_date - assumed 'reg_date' (this will throw an Error in a future version of PHP) in /home/redtea/html/a_skin/bbsd/view.php on line 53 19/11/27 22:07:47 Warning: Use of undefined constant mod_date - assumed 'mod_date' (this will throw an Error in a future version of PHP) in /home/redtea/html/a_skin/bbsd/view.php on line 56 |
Name | 로냐프 |
Subject | 파이썬 코딩 스타일 문의 |
안녕하세요? 요즘 파이썬으로 간단한 프로그램을 하나 짜고 있는데요. 1) 파이썬의 경우, class 멤버에 대해서 getter/setter를 통하기 보다는 그냥 직접 접근하는게 관례라고 하더군요. class멤버변수를 읽어가기만 하고 수정하는 경우는 없는데, 그래도 그냥 public으로 두는게 나을까요? 아니면 getter만 구현하고 다 숨기는게 나을까요? setter를 구현하지 않는 경우에도 @property를 쓰는게 더 나을까요? 2) A와 B class는 특정한 struct의 data를 저장하고 처리하는 class이고, C class는 여러 data를 file에 특정한 format으로 기록하는 class입니다. 그러다보니 C class를 사용하려면 A와 B의 모든 멤버를 다 읽어와야 하고, A/B class에서 모든 멤버에 대한 getter를 다 구현하고 있는데, 결국 A/B class는 C class에 대해서는 완전히 transparent합니다. 그렇다고, C class를 A class나 B class의 내부에 두기에는 C class자체가 사용자에게 직접 정보를 받는 부분도 많아서, A.to_C_class(args) 이런식으로 매번 A/B class에 그 인자를 전달하는 method를 추가해야 되는데, 그것도 보기가 별로 안 좋네요. 보통 이런 때는 어떤식으로 구현하게 될까요? 미리 감사합니다~ Warning: Use of undefined constant no - assumed 'no' (this will throw an Error in a future version of PHP) in /home/redtea/html/a_skin/bbsd/view.php on line 133 Warning: Use of undefined constant no - assumed 'no' (this will throw an Error in a future version of PHP) in /home/redtea/html/a_skin/bbsd/view.php on line 146 Warning: Use of undefined constant vote - assumed 'vote' (this will throw an Error in a future version of PHP) in /home/redtea/html/a_skin/bbsd/view.php on line 161 1 |
Warning: Use of undefined constant memo - assumed 'memo' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/lib.php on line 185
Warning: Use of undefined constant use_comment - assumed 'use_comment' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/view.php on line 540
Warning: Use of undefined constant name - assumed 'name' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/view.php on line 542
Warning: Use of undefined constant ismember - assumed 'ismember' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/view.php on line 543
Warning: Use of undefined constant memo - assumed 'memo' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/view.php on line 545
Warning: Use of undefined constant ismember - assumed 'ismember' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/view.php on line 576
Warning: Use of undefined constant ismember - assumed 'ismember' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/view.php on line 577
Warning: Use of undefined constant no - assumed 'no' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/view.php on line 577
Warning: Use of undefined constant level - assumed 'level' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/view.php on line 577
Warning: Use of undefined constant grant_delete - assumed 'grant_delete' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/view.php on line 577
Warning: Use of undefined constant ismember - assumed 'ismember' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/lib.php on line 425
Warning: Use of undefined constant ismember - assumed 'ismember' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/lib.php on line 429
Warning: Use of undefined constant use_formmail - assumed 'use_formmail' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/view.php on line 605
Warning: Use of undefined constant name - assumed 'name' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/lib.php on line 599
Warning: Use of undefined constant name - assumed 'name' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/lib.php on line 599
Warning: Use of undefined constant name - assumed 'name' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/lib.php on line 600
Warning: Use of undefined constant name - assumed 'name' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/lib.php on line 600
Warning: Use of undefined constant is_admin - assumed 'is_admin' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/lib.php on line 605
Warning: Use of undefined constant is_admin - assumed 'is_admin' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/lib.php on line 605
Warning: Use of undefined constant is_admin - assumed 'is_admin' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/lib.php on line 609
Warning: Use of undefined constant is_admin - assumed 'is_admin' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/lib.php on line 609
Warning: Use of undefined constant no - assumed 'no' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/lib.php on line 614
Warning: Use of undefined constant ismember - assumed 'ismember' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/lib.php on line 616
Warning: Use of undefined constant x - assumed 'x' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/lib.php on line 618
Warning: Use of undefined constant name - assumed 'name' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/lib.php on line 618
Warning: Use of undefined constant x - assumed 'x' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/view.php on line 612
Warning: Use of undefined constant name - assumed 'name' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/view.php on line 612
Warning: Use of undefined constant reg_date - assumed 'reg_date' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/view.php on line 620
Warning: Use of undefined constant ismember - assumed 'ismember' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/view.php on line 628
Warning: Use of undefined constant no - assumed 'no' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/view.php on line 628
Warning: Use of undefined constant HTTP_HOST - assumed 'HTTP_HOST' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/view.php on line 640
Warning: Use of undefined constant name - assumed 'name' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/view.php on line 644
Warning: Use of undefined constant no - assumed 'no' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/view.php on line 646
Warning: Use of undefined constant no - assumed 'no' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/view.php on line 646
Warning: Use of undefined constant HTTP_HOST - assumed 'HTTP_HOST' (this will throw an Error in a future version of PHP) in /home/redtea/html/pb/cmt_replace.php on line 3
Warning: Use of undefined constant ismember - assumed 'ismember' (this will throw an Error in a future version of PHP) in /home/redtea/html/a_skin/bbsd/view_comment.php on line 6
Warning: Use of undefined constant ismember - assumed 'ismember' (this will throw an Error in a future version of PHP) in /home/redtea/html/a_skin/bbsd/view_comment.php on line 22
Warning: Use of undefined constant file_name - assumed 'file_name' (this will throw an Error in a future version of PHP) in /home/redtea/html/a_skin/bbsd/view_comment.php on line 28
Warning: Use of undefined constant no - assumed 'no' (this will throw an Error in a future version of PHP) in /home/redtea/html/a_skin/bbsd/view_comment.php on line 65
74313 class="iamcmt" style="display:none;"> Warning: Use of undefined constant no - assumed 'no' (this will throw an Error in a future version of PHP) in /home/redtea/html/a_skin/bbsd/view_comment.php on line 66
74313 class='vcm '>
Warning: Use of undefined constant x - assumed 'x' (this will throw an Error in a future version of PHP) in /home/redtea/html/a_skin/bbsd/view_comment.php on line 70
Warning: Use of undefined constant x - assumed 'x' (this will throw an Error in a future version of PHP) in /home/redtea/html/a_skin/bbsd/view_comment.php on line 71
Warning: Use of undefined constant no - assumed 'no' (this will throw an Error in a future version of PHP) in /home/redtea/html/a_skin/bbsd/view_comment.php on line 76
Warning: Use of undefined constant ismember - assumed 'ismember' (this will throw an Error in a future version of PHP) in /home/redtea/html/a_skin/bbsd/view_comment.php on line 117
Warning: Use of undefined constant ismember - assumed 'ismember' (this will throw an Error in a future version of PHP) in /home/redtea/html/a_skin/bbsd/view_comment.php on line 118
Warning: Use of undefined constant ismember - assumed 'ismember' (this will throw an Error in a future version of PHP) in /home/redtea/html/a_skin/bbsd/view_comment.php on line 119
Warning: Use of undefined constant ismember - assumed 'ismember' (this will throw an Error in a future version of PHP) in /home/redtea/html/a_skin/bbsd/view_comment.php on line 120
Warning: Use of undefined constant ismember - assumed 'ismember' (this will throw an Error in a future version of PHP) in /home/redtea/html/a_skin/bbsd/view_comment.php on line 121

74313'> 오후다섯시
Warning: Use of undefined constant mod_date - assumed 'mod_date' (this will throw an Error in a future version of PHP) in /home/redtea/html/a_skin/bbsd/view_comment.php on line 133
Warning: Use of undefined constant no - assumed 'no' (this will throw an Error in a future version of PHP) in /home/redtea/html/a_skin/bbsd/view_comment.php on line 134
수정됨
Warning: Use of undefined constant no - assumed 'no' (this will throw an Error in a future version of PHP) in /home/redtea/html/a_skin/bbsd/view_comment.php on line 140
Warning: Use of undefined constant no - assumed 'no' (this will throw an Error in a future version of PHP) in /home/redtea/html/a_skin/bbsd/view_comment.php on line 140
Warning: Use of undefined constant reg_date - assumed 'reg_date' (this will throw an Error in a future version of PHP) in /home/redtea/html/a_skin/bbsd/view_comment.php on line 142
19/11/28 09:14
74313>삭제 주소복사
Warning: Use of undefined constant level - assumed 'level' (this will throw an Error in a future version of PHP) in /home/redtea/html/a_skin/bbsd/view_comment.php on line 150
1. 파이썬에서는 뭔가를 강제하겠다는 식의 접근은 대개 실패합니다. 오용하기 어렵게 할 수는 있지만 불가능하게는 못 한다. 그래서 정 필요하다면 그 자유를 누려라. 제약보다는 책임있는 사용을 하라. 그게 Pythonic한 거라고 생각합니다. 저라면 일단 변수를 public으로 뒀다가 특수한 제약이 필요해지면 관례에 따라 변수명에 underscore 붙여서 private로 표시한 뒤, property로 getter를 노출시켜서 인터페이스를 유지하여 코드 변경을 최소화할 것 같습니다.
2. 입력 데이터가 될 클래스(A, B등)는 ... 더 보기
2. 입력 데이터가 될 클래스(A, B등)는 ... 더 보기
1. 파이썬에서는 뭔가를 강제하겠다는 식의 접근은 대개 실패합니다. 오용하기 어렵게 할 수는 있지만 불가능하게는 못 한다. 그래서 정 필요하다면 그 자유를 누려라. 제약보다는 책임있는 사용을 하라. 그게 Pythonic한 거라고 생각합니다. 저라면 일단 변수를 public으로 뒀다가 특수한 제약이 필요해지면 관례에 따라 변수명에 underscore 붙여서 private로 표시한 뒤, property로 getter를 노출시켜서 인터페이스를 유지하여 코드 변경을 최소화할 것 같습니다.
2. 입력 데이터가 될 클래스(A, B등)는 무한히 다양하고, 데이터 출력이 되는 클래스(C)는 유한할 것으로 예상된다면. C가 A, B를 아는 것보다 A와 B가 자신의 정보를 C에 맞게 내어주는 게 아무래도 더 자연스럽겠죠. C클래스에 빌더 패턴을 적용하고, 외부에서 사용자 입력을 통해 절반정도 만들어진 C 빌더를 A.to_C_class()의 인자로 들어가게 하여 A나 B가 그 빌더 패턴에 따라 자신의 입맛에 맞게 C를 완성하도록 하면 좋을 것 같습니다.
2. 입력 데이터가 될 클래스(A, B등)는 무한히 다양하고, 데이터 출력이 되는 클래스(C)는 유한할 것으로 예상된다면. C가 A, B를 아는 것보다 A와 B가 자신의 정보를 C에 맞게 내어주는 게 아무래도 더 자연스럽겠죠. C클래스에 빌더 패턴을 적용하고, 외부에서 사용자 입력을 통해 절반정도 만들어진 C 빌더를 A.to_C_class()의 인자로 들어가게 하여 A나 B가 그 빌더 패턴에 따라 자신의 입맛에 맞게 C를 완성하도록 하면 좋을 것 같습니다.
Warning: Use of undefined constant level - assumed 'level' (this will throw an Error in a future version of PHP) in /home/redtea/html/a_skin/bbsd/view_comment.php on line 158
Warning: Use of undefined constant password - assumed 'password' (this will throw an Error in a future version of PHP) in /home/redtea/html/a_skin/bbsd/view_comment.php on line 166
Warning: Use of undefined constant vote - assumed 'vote' (this will throw an Error in a future version of PHP) in /home/redtea/html/a_skin/bbsd/view_comment.php on line 171
Warning: Use of undefined constant vote - assumed 'vote' (this will throw an Error in a future version of PHP) in /home/redtea/html/a_skin/bbsd/view_comment.php on line 172
Warning: Use of undefined constant no - assumed 'no' (this will throw an Error in a future version of PHP) in /home/redtea/html/a_skin/bbsd/view_comment.php on line 173
Warning: Use of undefined constant no - assumed 'no' (this will throw an Error in a future version of PHP) in /home/redtea/html/a_skin/bbsd/view_comment.php on line 173
Warning: Use of undefined constant vote - assumed 'vote' (this will throw an Error in a future version of PHP) in /home/redtea/html/a_skin/bbsd/view_comment.php on line 173
2
74313>
74313>