Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Capturepy captures the standard output and the standard error of functions, methods and any blocks of code. It is useful when testing, debugging and working with libraries. Find out more at https://github.com/GabrieleMaurina/capturepy.
Capturepy captures the standard output and the standard error of functions, methods and any blocks of code. It is useful when testing, debugging and working with libraries.
pip install capturepy
It requires python 3.8 or higher.
See the examples.py file for a complete list of examples.
This module is based on the class Capture, which can be use as a decorator, or with the 'with' statement.
Here are some examples:
from capturepy import Capture
print('Capture stdout and stderr of function using the Capture decorator.')
@Capture
def my_func(x):
print('first')
print('second', end='', file=sys.stderr)
return x**2
output, result = my_func(4)
print('The captured output is:')
print(output)
print('The function returned:')
print(result)
from capturepy import Capture
print('Capture only stderr of code using the "with" statement.')
with Capture(stdout=False) as capture:
print('first')
print('second', end='', file=sys.stderr)
stderr = capture.get()
print('The captured stderr is:')
print(stderr)
FAQs
Capturepy captures the standard output and the standard error of functions, methods and any blocks of code. It is useful when testing, debugging and working with libraries. Find out more at https://github.com/GabrieleMaurina/capturepy.
We found that capturepy demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.