Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #90591
| Date | 2015-05-13 19:54 -0400 |
|---|---|
| From | Peter <p-santoro@sbcglobal.net> |
| Subject | use of subprocess module inside generator |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.467.1431561493.12865.python-list@python.org> (permalink) |
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 comp.lang.python | Previous | Next | Find similar | Unroll thread
use of subprocess module inside generator Peter <p-santoro@sbcglobal.net> - 2015-05-13 19:54 -0400
csiph-web