Home
Stephen Thorne's Journal
 
[Most Recent Entries] [Calendar View] [Friends View]

Tuesday, September 6th, 2005

    Time Event
    9:33a
    funky 2.5 defgen
    This is the new syntax for using the new 2.5 generators with twisted.
    @defgen
    def foo():
      value = yield someDeferredAction()
      row = yield someDatabaseQuery(value+1)
      yield row['column']

    which is an analog of the 'old' way of doing things, like this:
    def foo():
      def _increment(value):
        return value+1
      def _getcolumn(row):
        return row['column']
      return someDeferredAction(
      ).addCallback(_increment
      ).addCallback(someDatabaseQuery
      ).addCallback(_getcolumn)

    Yay to christopher armstrong for putting this together, yay to PJE for writing the code for python2.5

    << Previous Day 2005/09/06
    [Calendar]
    Next Day >>

About LiveJournal.com

Advertisement