Using the stdout module redirects stdout to the response object, so you can use
print
!
redirecting stdout can be used to... ... for later:
capture output