Path: csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.040 X-Spam-Evidence: '*H*': 0.92; '*S*': 0.00; 'constructor': 0.09; 'exception,': 0.09; 'hiding': 0.09; 'subtle': 0.09; 'agreed,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'gained': 0.16; 'roy': 0.16; 'rule.': 0.16; 'prevent': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'do.': 0.18; 'code,': 0.22; 'string,': 0.24; "i've": 0.25; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'chris': 0.29; 'am,': 0.29; 'message- id:@mail.gmail.com': 0.30; 'code': 0.31; 'yourself.': 0.31; 'class': 0.32; 'cases': 0.33; 'received:209.85': 0.35; 'received:209.85.220': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'two': 0.37; 'received:209': 0.37; 'massive': 0.38; 'to:addr:python-list': 0.38; 'itself': 0.39; 'to:addr:python.org': 0.39; 'access,': 0.60; "you're": 0.61; 'skip:n 10': 0.64; 'smith': 0.68; 'acts': 0.74; 'article': 0.77; 'members:': 0.84; 'subject:skip:o 10': 0.84; 'yourself?': 0.84; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=bsTN0oB+LKC2QPhA5eOPVmd39qigVE6aWetjWjKLTt0=; b=iNNUO8fZXazQ9nsKmqJG6MlW7jKd181YeY9f6kz4/kai2GYi3g9WGl85/LXKQlMag/ 5kh4zBiPJRKkw6JewS+2L8+TUL94wE27hYlD6piByHMGnJUtVgVcC+co70Q6CEA2GU7B hlLrE57GjckqL3P+xnkO0C1ycxQHlNgabDEbh0xq0ozVdv8zuX3hs1G+qijQfu7/+sth NED01P1wlLsnJQo/jSeaOgmI2wFIK5OaqPqStcih5tbUfPwYEAsExlrjgMeR8u/YcN3G Jo30YnNybcuKwjmTN36SyBlyy4AXFgJpAvO+afZXuL+bkCq8wPjRgGa//3+P1pUPx0Qr DsFQ== MIME-Version: 1.0 X-Received: by 10.58.15.193 with SMTP id z1mr11541029vec.40.1368200672063; Fri, 10 May 2013 08:44:32 -0700 (PDT) In-Reply-To: References: <518a123c$0$11094$c3e8da3@news.astraweb.com> <518b32ef$0$11120$c3e8da3@news.astraweb.com> <518be931$0$29997$c3e8da3$5496439d@news.astraweb.com> <518c5bbc$0$29997$c3e8da3$5496439d@news.astraweb.com> <518c7f8e$0$29997$c3e8da3$5496439d@news.astraweb.com> <518cd360$0$29997$c3e8da3$5496439d@news.astraweb.com> Date: Sat, 11 May 2013 01:44:31 +1000 Subject: Re: object.enable() anti-pattern From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 21 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1368200674 news.xs4all.nl 15914 [2001:888:2000:d::a6]:41071 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:45111 On Sat, May 11, 2013 at 1:21 AM, Roy Smith wrote: > In article , > Chris Angelico wrote: >> >> Agreed, in generality. But what is actually gained by hiding data from >> yourself? > > You're not hiding it from yourself. You're hiding it from the other > people who are using your code and may not understand all the subtle > gotchas as well as you do. True. And on looking over my code, I find that there are a few cases where I've used private members: I have a buffer class that acts pretty much like a non-refcounted string, and it declares a private copy constructor to prevent accidental misuse. But it's the exception, not the rule. My main point isn't about the cases where you actually want to prevent access, but the all-too-common case where the member itself is private and there are two public methods to get and set it. Massive boilerplate. Completely unnecessary in 99%+ of cases. ChrisA