[Twisted-Python] Syntactic sugar for deferreds

Landreville landreville at deadtreepages.com
Mon Dec 7 08:30:38 MST 2009


On Mon, Dec 7, 2009 at 10:02 AM, ssteinerX at gmail.com <ssteinerx at gmail.com>wrote:

> On Dec 7, 2009, at 9:50 AM, Konrads Smelkovs wrote:
>
> > Hi,
> >
> > One project I had a look at had this nice syntactic sugar for async
> function chaining:
> >
> > >>> event_one() | event_two() | event_three()
> >
> > I think this could be an interesting alternative to addCallback or yield.
> I propose the following syntax
> >
> > # get deferred with one () and two () chained as callbacks, equivalent to
> d=Deferred().addCallback(one).addCallback(two)
> > >>> d = Deferred() | one | two
> >
> > # Equivalent to d=Deferred().addCallback(one).addErrback(two)
> > >>> d = Deferred() | one ^ two
> >
> > and finally:
> > # d=Deferred().addBoth(one,two)
> > >>> d = Deferred() & (one,two)
>
> Yuck.
>
> S
>
>
> I'd have to agree with this. Yield with inline callbacks is certainly
enough syntactic sugar for me.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20091207/813fd55b/attachment-0001.html>


More information about the Twisted-Python mailing list