Stephen Thorne ([info]jerub) wrote,
@ 2005-09-06 09:33:00
Previous Entry  Add to memories!  Tell a Friend  Next Entry
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


Advertisement


(Read 1 comment)

Post a comment in response:

From:
Help
Identity URL: 
Username:
Password:
Don't have an account? Create one now.
Subject:
No HTML allowed in subject
   Help
Message:

 
Notice! This user has turned on the option that logs your IP address when posting. Help
Create an Account
Forgot your login or password?
Login w/ OpenID
English • Español • Deutsch • Русский…