def default_listener(col_attr, default):
 @event.listens_for(col_attr, 'init_scalar', retval=True, propagate=True)
 def init_scalar(target, value, dict_):
  if default.is_callable:
   value = default.arg(None)
  elif default.is_scalar:
   value = default.arg
  else:
   raise NotImplementedError("Can't invoke pre-default for a SQL-level column default")
  dict_[col_attr.key] = value
  return value

def default_listener ( col_attr , default ) : @ event . listens_for ( col_attr , 'init_scalar' , retval = True , propagate = True ) def init_scalar ( target , value , dict_ ) : if default . is_callable : value = default . arg ( None ) elif default . is_scalar : value = default . arg else : raise NotImplementedError ( "Can't invoke pre-default for a SQL-level column default" ) dict_ [ col_attr . key ] = value return value
establish a default-setting listener .