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


Groups > comp.lang.python > #86124

Re: Design thought for callbacks

Path csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <cfkaran2@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.117
X-Spam-Level *
X-Spam-Evidence '*H*': 0.77; '*S*': 0.01; '22,': 0.09; 'bits': 0.09; 'callback': 0.09; 'function,': 0.09; 'referenced': 0.09; 'cc:addr :python-list': 0.11; '"in': 0.16; 'elsewhere,': 0.16; 'unbound': 0.16; 'thanks,': 0.17; 'wrote:': 0.18; 'feb': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'changes,': 0.26; 'holds': 0.26; 'certain': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'am,': 0.29; 'directly,': 0.31; 'existence': 0.31; 'but': 0.35; 'received:google.com': 0.35; 'much.': 0.36; 'object,': 0.36; 'yield': 0.36; 'method': 0.36; 'charset:us-ascii': 0.36; 'should': 0.36; 'too': 0.37; 'message-id:@gmail.com': 0.38; 'users': 0.40; 'results.': 0.60; "you're": 0.61; 'header:Message-Id:1': 0.63; 'notified': 0.63; 'anything.': 0.68; 'frank': 0.68; 'registers': 0.68; 'informed': 0.78; 'subject:Design': 0.78; 'inform': 0.78; '5:15': 0.84; 'gains': 0.84; 'listener': 0.84; 'presumably': 0.84; 'subject:thought': 0.84; 'state.': 0.95
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=yqlclrsyHrmJ1IwjsEYeBM8TyOWfVv+oculUZXbnSVs=; b=YjWrX0YxdYyYozS4O6AT3QOL7/vjdEcNmoPq9t07dzmoMvJErVCWhFhjxNMOT2r6Jo AzVHqP+mTybnGpg5G36xsyhEAzJzaVUdahwZ/yBWJ3vG+mdLNKigy4FC9//RJy9TOE67 710OR2djzirkTSuoifoyq7sr9RitfeT3sttl4TYBUa5r4G5E7R36xfsTknNAmiXthFvH aQ6WZS/Y4onEXJTcTm1WiUDj3b6v4erOtZ1dSIN65+ripHzl/A/wsnBSYvMYRqEOm7xC iUIyl2ZBHe9rI5rA/1rNJyq6G7bNoq7QsWiaiCkDIB4yDBsaMuaUebCzrUcGJZxaEtuw boEg==
X-Received by 10.52.85.132 with SMTP id h4mr6390529vdz.40.1424614967057; Sun, 22 Feb 2015 06:22:47 -0800 (PST)
Content-Type text/plain; charset=us-ascii
Mime-Version 1.0 (Mac OS X Mail 6.6 \(1510\))
Subject Re: Design thought for callbacks
From Cem Karan <cfkaran2@gmail.com>
In-Reply-To <cktoi3F7hlsU1@mid.individual.net>
Date Sun, 22 Feb 2015 09:22:45 -0500
Content-Transfer-Encoding quoted-printable
References <33677AE8-B2FA-49F9-9304-C8D93784255D@gmail.com> <mailman.18947.1424497301.18130.python-list@python.org> <54e8af1b$0$12976$c3e8da3$5496439d@news.astraweb.com> <mailman.18987.1424587462.18130.python-list@python.org> <cktoi3F7hlsU1@mid.individual.net>
To Gregory Ewing <greg.ewing@canterbury.ac.nz>
X-Mailer Apple Mail (2.1510)
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 <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.19016.1424614976.18130.python-list@python.org> (permalink)
Lines 27
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1424614976 news.xs4all.nl 2925 [2001:888:2000:d::a6]:35137
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:86124

Show key headers only | View raw


On Feb 22, 2015, at 5:15 AM, Gregory Ewing <greg.ewing@canterbury.ac.nz> wrote:

> Frank Millman wrote:
>> "In order to inform users that certain bits of state have changed, I require them to register a callback with my code."
>> This sounds to me like a pub/sub scenario. When a 'listener' object comes into existence it is passed a reference to a 'controller' object that holds state. It wants to be informed when the state changes, so it registers a callback function with the controller.
> 
> Perhaps instead of registering a callback function, you
> should be registering the listener object together with
> a method name.
> 
> You can then keep a weak reference to the listener object,
> since if it is no longer referenced elsewhere, it presumably
> no longer needs to be notified of anything.

I see what you're saying, but I don't think it gains us too much.  If I store an object and an unbound method of the object, or if I store the bound method directly, I suspect it will yield approximately the same results.

Thanks,
Cem Karan

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


Thread

Re: Design thought for callbacks "Frank Millman" <frank@chagford.com> - 2015-02-21 07:41 +0200
  Re: Design thought for callbacks Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-02-22 03:15 +1100
    Re: Design thought for callbacks Marko Rauhamaa <marko@pacujo.net> - 2015-02-21 19:08 +0200
      Re: Design thought for callbacks Cem Karan <cfkaran2@gmail.com> - 2015-02-22 07:16 -0500
        Re: Design thought for callbacks Marko Rauhamaa <marko@pacujo.net> - 2015-02-22 14:46 +0200
          Re: Design thought for callbacks Cem Karan <cfkaran2@gmail.com> - 2015-02-22 09:17 -0500
      Re: Design thought for callbacks Laura Creighton <lac@openend.se> - 2015-02-22 13:52 +0100
      Re: Design thought for callbacks Cem Karan <cfkaran2@gmail.com> - 2015-02-22 09:10 -0500
    Re: Design thought for callbacks "Frank Millman" <frank@chagford.com> - 2015-02-22 08:44 +0200
      Re: Design thought for callbacks Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2015-02-22 23:15 +1300
        Re: Design thought for callbacks Cem Karan <cfkaran2@gmail.com> - 2015-02-22 09:22 -0500
          Re: Design thought for callbacks Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2015-02-24 18:45 +1300
            Re: Design thought for callbacks Cem Karan <cfkaran2@gmail.com> - 2015-02-24 06:06 -0500
        Re: Design thought for callbacks Ian Kelly <ian.g.kelly@gmail.com> - 2015-02-22 23:57 -0700

csiph-web