Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #90591 > unrolled thread

use of subprocess module inside generator

Started byPeter <p-santoro@sbcglobal.net>
First post2015-05-13 19:54 -0400
Last post2015-05-13 19:54 -0400
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  use of subprocess module inside generator Peter <p-santoro@sbcglobal.net> - 2015-05-13 19:54 -0400

#90591 — use of subprocess module inside generator

FromPeter <p-santoro@sbcglobal.net>
Date2015-05-13 19:54 -0400
Subjectuse 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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web