Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #32394

Re: Nice solution wanted: Hide internal interfaces

Path csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <andrea.crotti.0@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.004
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'python,': 0.02; 'attribute': 0.05; 'problem:': 0.07; 'ugly': 0.07; 'objects.': 0.09; 'cc:addr:python-list': 0.10; '(but': 0.15; '"_"': 0.16; 'subject:interfaces': 0.16; 'cc:2**0': 0.23; 'this:': 0.23; 'user.': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'c++': 0.27; 'joe': 0.27; 'message-id:@mail.gmail.com': 0.27; 'dictionary': 0.29; 'methods.': 0.29; "i'm": 0.29; 'classes': 0.30; 'function': 0.30; 'instances': 0.33; "can't": 0.34; 'received:google.com': 0.34; 'received:209.85': 0.35; 'there': 0.35; 'created': 0.36; 'but': 0.36; '(i.e.': 0.36; 'does': 0.37; 'two': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'sure': 0.38; 'there,': 0.38; 'gives': 0.39; 'header:Received:5': 0.40; 'think': 0.40; 'real': 0.61; 'subject:Nice': 0.84
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 :cc:content-type; bh=GisPbibL4EwZdLChQeOJBeQak4nF1+YM2LsSTd1Nhks=; b=swo7HB13BhoaXqYoQjNFgx3W7c/3gNGPQ2l3IfRjzJZD5jJMmO2TYznW82BuweITSl 5HY/JKWzyELJwu+i0a33YChSvUvbwwpjONqqjBR0CmyI4A0ZwHoaYXixD5eGoti5mxb9 PBPYsMD9OhsJVR530oBanK6uBSBdhFhYDo1+sORsxf/OlFFzfp8PLkU78g6vhvS8DqfK NRoQ80eDHDwDTTnUKhTq7asySRDtIsNC6lD/HdhH8zjJfvJ66BzAwXzHJtpPK0Npz/Sm r49UrChYjWvnAFx9bg9aHIJUJtkuL4WJO2E5dEXxjUVOELB+94kZ3h2ZE3ACEioKVFxL HcZA==
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 16:41:57 +0000
Subject Re: Nice solution wanted: Hide internal interfaces
From andrea crotti <andrea.crotti.0@gmail.com>
To Johannes Bauer <dfnsonfsduifb@gmx.de>
Content-Type text/plain; charset=ISO-8859-1
Cc python-list@python.org
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.3027.1351528920.27098.python-list@python.org> (permalink)
Lines 26
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1351528920 news.xs4all.nl 6966 [2001:888:2000:d::a6]:51849
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:32394

Show key headers only | View raw


2012/10/29 Johannes Bauer <dfnsonfsduifb@gmx.de>:
> 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
>

And how are you declaring methods private?  Because there is no real
private attribute in Python, if you declare them with a starting "_"
they are still perfectly accessible..

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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