projects
/
python_utils.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
62b4b77
)
Convert comment into doctest.
author
Scott Gasch
<
[email protected]
>
Sun, 29 May 2022 22:06:35 +0000
(15:06 -0700)
committer
Scott Gasch
<
[email protected]
>
Sun, 29 May 2022 22:06:35 +0000
(15:06 -0700)
string_utils.py
patch
|
blob
|
history
diff --git
a/string_utils.py
b/string_utils.py
index dbd50f22bbe48b349dd69649f480a557cb7ba1c7..88fc91011042514f554a77ab5906491888d0c5e1 100644
(file)
--- a/
string_utils.py
+++ b/
string_utils.py
@@
-1247,16
+1247,15
@@
def strip_ansi_sequences(in_str: str) -> str:
class SprintfStdout(contextlib.AbstractContextManager):
"""
A context manager that captures outputs to stdout to a buffer
class SprintfStdout(contextlib.AbstractContextManager):
"""
A context manager that captures outputs to stdout to a buffer
- without printing them.
e.g.::
+ without printing them.
- with SprintfStdout() as buf:
- print("test")
- print("1, 2, 3")
- print(buf())
-
- This yields::
-
- 'test\\n1, 2, 3\\n'
+ >>> with SprintfStdout() as buf:
+ ... print("test")
+ ... print("1, 2, 3")
+ ...
+ >>> print(buf(), end='')
+ test
+ 1, 2, 3
"""
"""