Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.012 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'argument': 0.05; 'assign': 0.07; 'stops': 0.07; 'alter': 0.09; 'changes': 0.15; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'personally,': 0.16; 'programmers,': 0.16; 'programmers;': 0.16; 'rarely': 0.16; 'reedy': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'module': 0.19; '>>>': 0.22; 'aug': 0.22; 'documented': 0.24; 'example.': 0.24; 'skip:{ 20': 0.24; 'values': 0.27; 'header:In- Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; 'possibility': 0.29; 'respective': 0.29; 'primarily': 0.30; 'message- id:@mail.gmail.com': 0.30; 'fixing': 0.31; 'says': 0.33; 'becomes': 0.33; 'programmers': 0.33; 'used,': 0.33; 'comment': 0.34; 'maybe': 0.34; 'could': 0.34; 'something': 0.35; 'test': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'really': 0.36; 'subject:?': 0.36; 'project': 0.37; 'clear': 0.37; 'easily': 0.37; 'being': 0.38; 'manager': 0.38; 'to:addr:python- list': 0.38; 'fact': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'users': 0.40; 'how': 0.40; 'future': 0.60; 'affect': 0.61; 'collective': 0.91; 'thoroughly': 0.91; 'subject:skip:E 10': 0.95; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=teF9uQ+YZn3MrF36xTOBHzwAVCJOzup1BtB5N44a4W0=; b=DVjGzMi8MAqSeCda+Poq2kSUhf46FtEKNE/ju/XE743PvpUuvfN0voIxXkvRpknG3c 5kj4ygTZomKLl2e3fPG8Oi1HwwLQ6rlfnq+rV0tbkPVaSroAEfMfoDf80cqwti6nAuDo 56WGEqnGYrOmxtUkH8NB8ZA7STt7yAqmIvwnCkx2nZt0J8Qc6CkocfGi1kBXk+ufD6h5 c45BDKwPc0XRrZM5zW3YQqZFj1k2oxBIi52hgo10aRoSw60Qko1w837QKtwsVz78jnAs FqAJwVjHnlQ76ineZAuA/cYwEUJ5zyaiwlM30p8sav+DEi9jdqr2HblYyzSdh6Jhh262 5Njg== MIME-Version: 1.0 X-Received: by 10.52.73.135 with SMTP id l7mr4805899vdv.9.1376787550466; Sat, 17 Aug 2013 17:59:10 -0700 (PDT) In-Reply-To: References: <8255dfbd-a2a1-4ab7-b900-ee19faa459f2@googlegroups.com> Date: Sun, 18 Aug 2013 01:59:10 +0100 Subject: Re: Encapsulation unpythonic? 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: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1376787558 news.xs4all.nl 15968 [2001:888:2000:d::a6]:47750 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:52647 On Sat, Aug 17, 2013 at 10:22 PM, Terry Reedy wrote: > On 8/17/2013 11:50 AM, Chris Angelico wrote: >> >> On Sat, Aug 17, 2013 at 1:26 PM, wrote: >>> >>> 2) If it is in fact true that encapsulation is rarely used, how do I deal >>> with the fact that other programmers can easily alter the values of members >>> of my classes? >> >> Very simply: You accept it. Let them! It's their responsibility. > > > When a project has multiple programmers, there is a possibility that module > C could monkeypatch module A in a way that breaks existing user module B. > But it is still the collective responsibility of the respective users or > project manager to assign responsibility for fixing the conflict. Yep. I would say there that the responsibility is with module C's programmers; they are the ones breaching encapsulation, ergo it's primarily their responsibility to both test this (against current usage) and thoroughly document it (against future changes). Personally, I would like to see a comment in module A that says something like "NOTE: This {function|attribute|spam} is replaced externally under [some circumstance]. Changes to its purpose may affect Module B." to make it clear what's going on. At that point, of course, it stops being monkeypatching and becomes documented and official behaviour, so maybe that's not really an argument in this example. ChrisA