Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4a.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.010 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'socket': 0.07; '22,': 0.09; 'callback': 0.09; 'sure,': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'bind': 0.16; 'bucket': 0.16; 'dump': 0.16; 'expect,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'opposite': 0.16; 'pov.': 0.16; 'with?': 0.16; 'wrote:': 0.18; 'do.': 0.18; 'seems': 0.21; 'feb': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'header:In-Reply- To:1': 0.27; "doesn't": 0.30; 'message-id:@mail.gmail.com': 0.30; "d'aprano": 0.31; 'steven': 0.31; 'skip:b 30': 0.33; 'but': 0.35; 'received:google.com': 0.35; 'done': 0.36; 'should': 0.36; 'wrong': 0.37; 'skip:o 20': 0.38; 'pm,': 0.38; 'expect': 0.39; 'skip:b 40': 0.39; 'read': 0.60; 'name': 0.63; 'subject:Design': 0.78; '2015': 0.84; 'intuit': 0.84; 'listener': 0.84; 'subject:thought': 0.84; 'to:none': 0.92 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:cc :content-type; bh=HvC4cFycTYfEXMVNsle0CgT493pEmeo8NV73b/vJnVo=; b=oZExPm3Y9kkOz7g1lOOlIaiA0nxSzHof4aqRty/IPQmZDAyfKTVEn0LSbuCPeMNRnm Rrsayfen2ijDqzzLts3KswwOOpTYkoCKq7ZYD+vVxj7f7vyHG7S2xLMihAz3ZWX5bA/I bRD/SRy1uQqlZ+y433waoC55w7nJ1bHyEnGX7YDt7mux2iWE8TAi0NGUoHwMDmFHGnSv LQZAf+Hg+VPOBLMnQyyuqiXZzj22uBZodmQUaTI7Gi6KSL9PwNjw9r9ulp3pbPqHOUwd cy11xHxttyUm4Cl4Z1vaKhIO/bU13z5+yEzSuaE9SA1MXWn2OFXbFZNEdvVRwRfjHpaP +mZQ== MIME-Version: 1.0 X-Received: by 10.107.160.212 with SMTP id j203mr6864735ioe.43.1424586060478; Sat, 21 Feb 2015 22:21:00 -0800 (PST) In-Reply-To: <54e95d34$0$13006$c3e8da3$5496439d@news.astraweb.com> References: <33677AE8-B2FA-49F9-9304-C8D93784255D@gmail.com> <87egpjapxv.fsf@elektro.pacujo.net> <54e9391b$0$13010$c3e8da3$5496439d@news.astraweb.com> <54e95d34$0$13006$c3e8da3$5496439d@news.astraweb.com> Date: Sun, 22 Feb 2015 17:21:00 +1100 Subject: Re: Design thought for callbacks From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 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: 1424586063 news.xs4all.nl 2841 [2001:888:2000:d::a6]:41456 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:86082 On Sun, Feb 22, 2015 at 3:38 PM, Steven D'Aprano wrote: > But you are using it. You might not be using it by name, but you are using > it via the callback function. What did you expect, that Python should read > your mind and somehow intuit that you still care about this socket > listener, but not some other socket listener that you are done with? > > You don't have to bind the listener to a name. Any reference will do. You > can dump it in a bucket: > > bucket_of_stuff = [] > bucket_of_stuff.append(some_function(a, b, c)) > bucket_of_stuff.append(make_web_server()) > bucket_of_stuff.append(socket(23, on_accept=client_connected)) Sure, and whether it's a name or a list-element reference doesn't matter: it seems wrong to have to stash a thing in a bucket in order to keep its callbacks alive. I expect the callbacks _themselves_ to keep it alive. But I can understand the opposite POV. ChrisA