Skip to main content

Capture the stdout or stderr output as a list in a context manager block (with).

Project description

This package on the Python Package Index Tests

stdout_stderr_capturing

Capture the stdout or stderr output as a list in a context manager block (with).

Maybe better alternatives:

Capture stdout:

with Capturing() as output:
    print('line 1')

print(output[0])

is equivalent to

with Capturing(stream='stdout') as output:
    print('line 1')

Capture stderr:

with Capturing(stream='stderr') as output:
    print('line 1', file=sys.stderr)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

stdout_stderr_capturing-0.2.1.tar.gz (2.7 kB view hashes)

Uploaded Source

Built Distribution

stdout_stderr_capturing-0.2.1-py3-none-any.whl (3.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page