[Twisted-Python] Current callback best practices

Laurens Van Houtven _ at lvh.cc
Tue Apr 2 07:11:41 EDT 2013


I use closures unless I use the same callback all the time.
On Apr 2, 2013 1:04 PM, "Hynek Schlawack" <hs at ox.cx> wrote:

> Hi,
>
> I’ve asked this one already at the Twisted dinner (thanks again for it, it
> was probably my PyCon highlight) and got various answers from people
> sitting around me. I’m still indecisive so I’d like to gather even more
> opinions[1]. I already tried to ask on IRC but my time zone is just not
> very #twisted friendly so I got zero replies.
>
> My question can be simplified to: Closures yes or no?
>
> They seem *really* handy since they allow to have some data present
> without handing it through all the time. Eg in my cred checker, I can refer
> to the user name from the closure instead of passing it around all the time
> – making the code much cleaner. Also most current examples and
> callbacks-are-hard-FUD-rebuttals seem to use them.
>
> OTOH, private methods like `_cbPrintResult` are nicer to test individually.
>
> If “yes, closures”: Still using cb/eb prefixes? I don’t see them very
> often in recent examples. What about addBoth handlers?
>
> Bonus points for the preferred style for the Twisted code base.
>
> Thanks in advance & thank you for your time,
> Hynek
>
> [1]: I’d be glad if people from the dinner replied again too so I/we have
> it in written form, my memory tends to be rather sloppy.
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20130402/cab7bed2/attachment.htm 


More information about the Twisted-Python mailing list