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.
Install
pip install capturepy
It requires python 3.8 or higher.
Usage
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:
Capturing output of function
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)
Capturing only standard error of code using "with" statement
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)
Metadata
Release files for capturepy 1.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| capturepy-1.0.3.tar.gz | 2.3 kB | Without provenance | Details for capturepy-1.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| capturepy-1.0.3-py3-none-any.whl | Python 3 | none | any | Details for capturepy-1.0.3-py3-none-any.whl |
Total release size: 5.7 kB
Release files / capturepy-1.0.3.tar.gz
| Download URL | capturepy-1.0.3.tar.gz |
|---|---|
| Size | 2.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
beffa6171f44a150cff147526075d1b39d9d34df5538d26071a04c2c46be1b4a
|
|
BLAKE2b-256 checksum How to use checksums |
283545ac000a321733dafcfce705b25a6b0bc11c404cd88f2b9eb97e95c2114b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.0
|
Release files / capturepy-1.0.3-py3-none-any.whl
| Download URL | capturepy-1.0.3-py3-none-any.whl |
|---|---|
| Size | 3.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
24965581c67c0a229a2486b8ea3272b6ffe2be4b77b693ef24e381420e0be0bd
|
|
BLAKE2b-256 checksum How to use checksums |
78e0ef86843a67e1d4358191bf4a75de071c63dbd3767cb569c3da88c966adbc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.0
|
Security for capturepy 1.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.