Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #86155
| Subject | Re: Design thought for callbacks |
|---|---|
| From | Cem Karan <cfkaran2@gmail.com> |
| Date | 2015-02-22 16:17 -0500 |
| References | (3 earlier) <CAPTjJmrfMowbK7z+eN7xfMv2Ck5peJpBPyBRHvhXM4-ocxRR6w@mail.gmail.com> <mailman.18962.1424527666.18130.python-list@python.org> <54e8c017$0$13008$c3e8da3$5496439d@news.astraweb.com> <51947083-01AC-4D1E-ACBD-3C476446B527@gmail.com> <54EA43C8.2090309@stoneleaf.us> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.19029.1424639844.18130.python-list@python.org> (permalink) |
On Feb 22, 2015, at 4:02 PM, Ethan Furman <ethan@stoneleaf.us> wrote: > On 02/22/2015 05:13 AM, Cem Karan wrote: > >> Output: >> From Evil Zombie: Surprise! >> From Your Significant Other: Surprise! >> >> In this case, the user made an error (just as Marko said in his earlier message), >> and forgot about the callback he registered with the library. The callback isn't >> really rising from the dead; as you say, either its been garbage collected, or it >> hasn't been. However, you may not be ready for a callback to be called at that >> moment in time, which means you're surprised by unexpected behavior. > > But the unexpected behavior is not a problem with Python, nor with your library -- it's a bug in the fellow-programmer's > code, and you can't (or at least shouldn't) try to prevent those kinds of bugs from manifesting -- they'll just get > bitten somewhere else by the same bug. I agree with you, but until a relatively new programmer has gotten used to what callbacks are and what they imply, I want to make things easy. For example, if the API subclasses collections.abc.MutableSet, and the documentation states that you can only add callbacks to this particular type of set, then a new programmer will naturally decide that either a) they need to dispose of the set, and if that isn't possible, then b) they need to delete their callback from the set. It won't occur to them that their live object will just magically 'go away'; its a member of a set! My goal is to make things as pythonic (whatever that means in this case) and obvious as possible. Ideally, a novice can more or less guess what will happen with my API without really having to read the documentation on it. Thanks, Cem Karan
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Design thought for callbacks Cem Karan <cfkaran2@gmail.com> - 2015-02-21 09:07 -0500
Re: Design thought for callbacks Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-02-22 04:27 +1100
Re: Design thought for callbacks Cem Karan <cfkaran2@gmail.com> - 2015-02-22 08:13 -0500
Re: Design thought for callbacks Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-02-24 00:31 +1100
Re: Design thought for callbacks Ethan Furman <ethan@stoneleaf.us> - 2015-02-22 13:02 -0800
Re: Design thought for callbacks Cem Karan <cfkaran2@gmail.com> - 2015-02-22 16:17 -0500
Re: Design thought for callbacks Marko Rauhamaa <marko@pacujo.net> - 2015-02-22 23:34 +0200
Re: Design thought for callbacks Cem Karan <cfkaran2@gmail.com> - 2015-02-22 17:09 -0500
Re: Design thought for callbacks Laura Creighton <lac@openend.se> - 2015-02-22 23:29 +0100
Re: Design thought for callbacks Chris Angelico <rosuav@gmail.com> - 2015-02-23 09:41 +1100
Re: Design thought for callbacks Cem Karan <cfkaran2@gmail.com> - 2015-02-23 06:47 -0500
Re: Design thought for callbacks "Frank Millman" <frank@chagford.com> - 2015-02-23 14:29 +0200
Re: Design thought for callbacks Cem Karan <cfkaran2@gmail.com> - 2015-02-24 06:00 -0500
csiph-web