Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #32395
| Path | csiph.com!usenet.pasdenom.info!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <bsk16@case.edu> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.011 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'problem:': 0.07; 'ugly': 0.07; 'python': 0.09; 'convention,': 0.09; 'objects.': 0.09; 'underscore': 0.09; '(but': 0.15; 'oct': 0.16; 'subject:interfaces': 0.16; 'mon,': 0.16; 'wrote:': 0.17; 'this:': 0.23; 'user.': 0.23; 'header:In-Reply-To:1': 0.25; 'am,': 0.27; 'language.': 0.27; 'c++': 0.27; 'joe': 0.27; 'message- id:@mail.gmail.com': 0.27; "doesn't": 0.28; 'dictionary': 0.29; 'methods.': 0.29; 'restricted': 0.29; "i'm": 0.29; 'classes': 0.30; 'function': 0.30; 'header:Received:8': 0.30; 'received:74.125.82': 0.33; 'instances': 0.33; 'to:addr:python- list': 0.33; "can't": 0.34; 'received:google.com': 0.34; 'created': 0.36; 'but': 0.36; 'received:74.125': 0.36; '(i.e.': 0.36; 'does': 0.37; 'two': 0.37; 'subject:: ': 0.38; 'mean': 0.38; 'some': 0.38; 'sure': 0.38; 'there,': 0.38; 'gives': 0.39; 'to:addr:python.org': 0.39; 'think': 0.40; 'leading': 0.61; 'enforced': 0.84; 'notion': 0.84; 'subject:Nice': 0.84 |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:x-gm-message-state; bh=iRJEzQ8N74E4nrqPIHOYu9guwAhvj1THVPQNWWU60dc=; b=GxKD2d9XpJIxeCAOFT0WL/zyUgtPiHplgpglQimXuXolIKxkl2LUgFCbP6GlvftC54 EgYFgXmeJNNWpIAvQLGCqS1JDXZw18g2Kb6ntoOeHmnFZEC1xnJOnRy6HRwMsmBr35GJ nDdgQMD3KWtAU9/PC9VkY+8IvTehW1I7+WIA/3bRmtDIUsVc8t6a9Db7QOvwfgrI1IG1 3dPCYrA9ogHQDXxruPk2XcAZgr1DRk4LMD+EIlaj0Is9arJ3pi2GZj615GgVnX3N+gmr kaES3sd1mRNcbNvJSahx6EcO0bfOek6YNf6yFXxPIW3x2vS/cleaFnkXpdf7aWv5tdcJ iMCg== |
| MIME-Version | 1.0 |
| In-Reply-To | <k6mb4k$5v3$1@news.albasani.net> |
| References | <k6mb4k$5v3$1@news.albasani.net> |
| Date | Mon, 29 Oct 2012 09:41:56 -0700 |
| Subject | Re: Nice solution wanted: Hide internal interfaces |
| From | Benjamin Kaplan <benjamin.kaplan@case.edu> |
| To | python-list@python.org |
| Content-Type | text/plain; charset=UTF-8 |
| X-Gm-Message-State | ALoCoQmWeA6cW5+bRJawvC3+B1SNe1G+qQ2Vo4Jyy1KpyuNWS/g+DjwtmPtgXH/R/vr94VwhsjYuUvZPOBMWZpAF+IQnTstBmIHbE2YuIpFIjww9M1p1FpqmswSJlv1UA69R97DsaQLiFmAHFc7NYWDsf76FEHIiFA== |
| X-Junkmail-Whitelist | YES (by domain whitelist at mpv1.tis.cwru.edu) |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3028.1351529114.27098.python-list@python.org> (permalink) |
| Lines | 27 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1351529114 news.xs4all.nl 6950 [2001:888:2000:d::a6]:55574 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:32395 |
Show key headers only | View raw
On Mon, Oct 29, 2012 at 9:33 AM, Johannes Bauer <dfnsonfsduifb@gmx.de> wrote: > Hi there, > > I'm currently looking for a good solution to the following problem: I > have two classes A and B, which interact with each other and which > interact with the user. Instances of B are always created by A. > > Now I want A to call some private methods of B and vice versa (i.e. what > C++ "friends" are), but I want to make it hard for the user to call > these private methods. > > Currently my ugly approach is this: I delare the internal methods > private (hide from user). Then I have a function which gives me a > dictionary of callbacks to the private functions of the other objects. > This is in my opinion pretty ugly (but it works and does what I want). > > I'm pretty damn sure there's a nicer (prettier) solution out there, but > I can't currently think of it. Do you have any hints? > > Best regards, > Joe > What do you mean "declare the internal methods private"? Python doesn't have this notion of restricted access. By convention, names starting with a leading underscore are private, but it's not enforced by the language.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Nice solution wanted: Hide internal interfaces Johannes Bauer <dfnsonfsduifb@gmx.de> - 2012-10-29 17:33 +0100
Re: Nice solution wanted: Hide internal interfaces andrea crotti <andrea.crotti.0@gmail.com> - 2012-10-29 16:41 +0000
Re: Nice solution wanted: Hide internal interfaces Benjamin Kaplan <benjamin.kaplan@case.edu> - 2012-10-29 09:41 -0700
Re: Nice solution wanted: Hide internal interfaces Chris Angelico <rosuav@gmail.com> - 2012-10-30 03:47 +1100
Re: Nice solution wanted: Hide internal interfaces Johannes Bauer <dfnsonfsduifb@gmx.de> - 2012-10-29 17:58 +0100
Re: Nice solution wanted: Hide internal interfaces Paul Rubin <no.email@nospam.invalid> - 2012-10-29 10:03 -0700
Re: Nice solution wanted: Hide internal interfaces Grant Edwards <invalid@invalid.invalid> - 2012-10-29 18:00 +0000
Re: Nice solution wanted: Hide internal interfaces Ian Kelly <ian.g.kelly@gmail.com> - 2012-10-29 13:09 -0600
Re: Nice solution wanted: Hide internal interfaces Grant Edwards <invalid@invalid.invalid> - 2012-10-29 16:52 +0000
Re: Nice solution wanted: Hide internal interfaces Johannes Bauer <dfnsonfsduifb@gmx.de> - 2012-10-29 18:01 +0100
Re: Nice solution wanted: Hide internal interfaces Peter Otten <__peter__@web.de> - 2012-10-29 18:17 +0100
Re: Nice solution wanted: Hide internal interfaces Peter Otten <__peter__@web.de> - 2012-10-29 18:06 +0100
Re: Nice solution wanted: Hide internal interfaces Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-10-29 22:37 +0000
Re: Nice solution wanted: Hide internal interfaces alex23 <wuwei23@gmail.com> - 2012-10-29 18:37 -0700
Re: Nice solution wanted: Hide internal interfaces andrea crotti <andrea.crotti.0@gmail.com> - 2012-10-30 14:15 +0000
csiph-web