# captures temporarily stdout and stderr
## Tested against Windows 10 / Python 3.10 / Anaconda
## pip install stderrstdoutcapture
### GetStdErr
```python
A context manager that captures and temporarily redirects standard error (stderr) to a list.
Usage:
from stderrstdoutcapture import GetStdErr
def errtest():
try:
x = 5 / 0
except Exception:
return "error"
with GetStdErr() as o2:
returnvalue2 = errtest()
print(o2) # Access captured stderr as a list
print(f"{returnvalue2=}") # Display the return value of the function
Methods:
__enter__(*args, **kwargs): Enter the context and redirect stderr to a StringIO buffer.
__exit__(*args, **kwargs): Exit the context and append the captured stderr to the list.
```
### GetStdOut
```python
A context manager that captures and temporarily redirects standard output (stdout) to a list.
Usage:
from stderrstdoutcapture import GetStdOut
def outtest():
try:
x = 5 / 5
print("five devided by five is one")
return x
except Exception:
pass
with GetStdOut() as o1:
returnvalue1 = outtest()
print(o1) # Access captured stdout as a list
print(f"{returnvalue1=}") # Display the return value of the function
Methods:
__enter__(*args, **kwargs): Enter the context and redirect stdout to a StringIO buffer.
__exit__(*args, **kwargs): Exit the context and append the captured stdout to the list.
```
Raw data
{
"_id": null,
"home_page": "https://github.com/hansalemaos/stderrstdoutcapture",
"name": "stderrstdoutcapture",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "capture,stdout,stderr",
"author": "Johannes Fischer",
"author_email": "aulasparticularesdealemaosp@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/8d/a5/57b5002187fff50bdb73321f9cfd43a7a69c10adbec0e09d3c30ebccabbc/stderrstdoutcapture-0.10.tar.gz",
"platform": null,
"description": "\r\n# captures temporarily stdout and stderr\r\n\r\n## Tested against Windows 10 / Python 3.10 / Anaconda\r\n\r\n## pip install stderrstdoutcapture\r\n\r\n### GetStdErr\r\n\r\n```python\r\nA context manager that captures and temporarily redirects standard error (stderr) to a list.\r\n\r\nUsage:\r\n\tfrom stderrstdoutcapture import GetStdErr\r\n\r\n\tdef errtest():\r\n\ttry:\r\n\t\tx = 5 / 0\r\n\texcept Exception:\r\n\t\treturn \"error\"\r\n\r\n\twith GetStdErr() as o2:\r\n\t\treturnvalue2 = errtest()\r\n\tprint(o2) # Access captured stderr as a list\r\n\tprint(f\"{returnvalue2=}\") # Display the return value of the function\r\n\r\nMethods:\r\n\t__enter__(*args, **kwargs): Enter the context and redirect stderr to a StringIO buffer.\r\n\t__exit__(*args, **kwargs): Exit the context and append the captured stderr to the list.\r\n\r\n```\r\n\r\n### GetStdOut\r\n\r\n\r\n```python\r\nA context manager that captures and temporarily redirects standard output (stdout) to a list.\r\n\r\nUsage:\r\n\tfrom stderrstdoutcapture import GetStdOut\r\n\tdef outtest():\r\n\t\ttry:\r\n\t\t\tx = 5 / 5\r\n\t\t\tprint(\"five devided by five is one\")\r\n\t\t\treturn x\r\n\t\texcept Exception:\r\n\t\t\tpass\r\n\r\n\twith GetStdOut() as o1:\r\n\t\treturnvalue1 = outtest()\r\n\tprint(o1) # Access captured stdout as a list\r\n\tprint(f\"{returnvalue1=}\") # Display the return value of the function\r\n\r\nMethods:\r\n\t__enter__(*args, **kwargs): Enter the context and redirect stdout to a StringIO buffer.\r\n\t__exit__(*args, **kwargs): Exit the context and append the captured stdout to the list.\r\n```\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "captures temporarily stdout and stderr",
"version": "0.10",
"project_urls": {
"Homepage": "https://github.com/hansalemaos/stderrstdoutcapture"
},
"split_keywords": [
"capture",
"stdout",
"stderr"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "60c35e633b8a5fb6bfcac2705b2b3c22da403c0eeccb63bf944e8dec5a2d8f35",
"md5": "4304379372b5d12ac492dcf3436bd4ab",
"sha256": "e37a6a8d4bc392f308866f20ee42fbdb494f63a0397aea7789829f8ace2962f3"
},
"downloads": -1,
"filename": "stderrstdoutcapture-0.10-py3-none-any.whl",
"has_sig": false,
"md5_digest": "4304379372b5d12ac492dcf3436bd4ab",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 4535,
"upload_time": "2023-09-04T21:08:34",
"upload_time_iso_8601": "2023-09-04T21:08:34.196038Z",
"url": "https://files.pythonhosted.org/packages/60/c3/5e633b8a5fb6bfcac2705b2b3c22da403c0eeccb63bf944e8dec5a2d8f35/stderrstdoutcapture-0.10-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8da557b5002187fff50bdb73321f9cfd43a7a69c10adbec0e09d3c30ebccabbc",
"md5": "90d8a87397ec5b9700d299ca829b4d7d",
"sha256": "36d889a09cdddb40ca5213c0318d47fd8f5b5ab4a5c7fa4361d92e01b6839f4e"
},
"downloads": -1,
"filename": "stderrstdoutcapture-0.10.tar.gz",
"has_sig": false,
"md5_digest": "90d8a87397ec5b9700d299ca829b4d7d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 3275,
"upload_time": "2023-09-04T21:08:35",
"upload_time_iso_8601": "2023-09-04T21:08:35.785744Z",
"url": "https://files.pythonhosted.org/packages/8d/a5/57b5002187fff50bdb73321f9cfd43a7a69c10adbec0e09d3c30ebccabbc/stderrstdoutcapture-0.10.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-09-04 21:08:35",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "hansalemaos",
"github_project": "stderrstdoutcapture",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "stderrstdoutcapture"
}