def collecting_callback():
 calls = []
 def cb(**kwargs):
  calls.append(kwargs)
 return (cb, calls)

def collecting_callback ( ) : calls = [ ] def cb ( ** kwargs ) : calls . append ( kwargs ) return ( cb , calls )
create and return a callback and a list populated with call args .