Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #90591 > unrolled thread
| Started by | Peter <p-santoro@sbcglobal.net> |
|---|---|
| First post | 2015-05-13 19:54 -0400 |
| Last post | 2015-05-13 19:54 -0400 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
use of subprocess module inside generator Peter <p-santoro@sbcglobal.net> - 2015-05-13 19:54 -0400
| From | Peter <p-santoro@sbcglobal.net> |
|---|---|
| Date | 2015-05-13 19:54 -0400 |
| Subject | use of subprocess module inside generator |
| Message-ID | <mailman.467.1431561493.12865.python-list@python.org> |
Gary,
Thank you for the response. I made a small typo in my original post,
which you correctly picked up. My original generator actually did not
have the stdout parameter (see below). Only the new generator has this
parameter, as it's now being passed into the generator from the caller's
execution of subprocess.check_output.
def _raw_data(cl, *, opath=None, timeout=timeout):
stdout = subprocess.check_output(cl, universal_newlines=True,
timeout=timeout)
if opath is None:
for line in stdout.splitlines():
yield line.strip()
else:
with open(opath) as f:
for line in f:
yield line.strip()
Peter
Back to top | Article view | comp.lang.python
csiph-web