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


Groups > comp.lang.python > #90591

use of subprocess module inside generator

Path csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <p-santoro@sbcglobal.net>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.030
X-Spam-Evidence '*H*': 0.94; '*S*': 0.00; 'else:': 0.03; 'none:': 0.07; 'below).': 0.09; 'parameter': 0.09; 'subject:module': 0.09; 'def': 0.12; 'stdout': 0.16; 'subject:generator': 0.16; 'typo': 0.16; 'header:User-Agent:1': 0.23; '(see': 0.26; 'up.': 0.33; 'skip:_ 10': 0.34; 'skip:u 20': 0.35; 'yield': 0.36; 'being': 0.38; 'thank': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'new': 0.61; 'header:Reply-To:1': 0.67; 'response.': 0.68; 'received:gq1.yahoo.com': 0.68; 'received:mail.gq1.yahoo.com': 0.68; 'reply-to:no real name:2**0': 0.71; 'received:bullet.mail.gq1.yahoo.com': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=sbcglobal.net; s=s2048; t=1431561286; bh=UMSYIZL6IMIVIVts8RXIgbUbsghZZNd0Ptzd18LPFiM=; h=Date:From:Reply-To:To:Subject:From:Subject; b=saYnZl054XeWgxx5jjly70OvD2tBouhV1gPsCaxSZIA23EYhTnms8g5B7XnOT9GX6LDmHc+etua7jJ5JeFvp9t69EOL0KjqKy1ydsbZGAvcxodiuZENtDEQX8sjleFWXyEIvLl3swRZQlaZ7G11EAhWtOroIfSiWJn0OlA3sZZYI/tzgb2vFpsYDHZvRj0CAK1HShN6OI1hsigUqyKVUvXH6XEqrW2yMYIICM3YvZKTMTGSG3I/JCxUAZUzaFAuld4LXEb2jM0gssRHrxpb1UM1eduDLFILJU76xHIm3tCAM8+wbrlWexn4sW8kLrkqJG2IBGf2cLINk4xwwJ55rYA==
X-Yahoo-Newman-Id 958859.1537.bm@smtp118.sbc.mail.ne1.yahoo.com
X-Yahoo-Newman-Property ymail-3
X-YMail-OSG 0_xpDq0VM1k7MTJ4PGLgEtq8cORB8NT9t2cZ0x0EAn3vRQP KVmUklZR.5htE3_usOjfE9aUK.xjt6j7J7Vy1jXcOS4YLU8VAMSgBXL7U8zF j0hRNzxbEOmu9aFF6JJpbLB.Ob3B102lcJgDQ522xK_QixDlBUhBYDrCrAv5 w.Jj0cFZFhUxWyYH6.6lxP.sa.hdhqST1JUPMJUlf8ourquMTgC1t_4JirEM NvvjWoTz_ZIZxFF9U74Zh2mYHc5gDCq78OAbK41ZxcMKTmJNVu0AFEkrQj.o 3U5vumTtCienrPWGVYLV4GAT633.Jpid3vMRVHicuDZzmSMIhk5HJtw0inOU tWMq67mslLBvySl9zF.fML_91YaNEv5Nbk68V6SAdmWug0gYE1mQ7th7.HmK eG2n2m1r1OxF9axtFZSnG4QKLj1l.uYO_x3eqF6DTjPQe7hIqWMuqlLo8utK r1wTVHE.mj9KV4JDtvA23YvlcusAEbuYJHCoTEQTI.LKkIon6NBbESR2JB2. rpGTy8QyT_xPTYmysUd8viOnKc5ist4WaUJX6zkXJoCAALNRyVyg88pE8
X-Yahoo-SMTP PcRdH1CswBDjJunwicc5apkCQkeGfezTDkgQJyBKPzChimw2
Date Wed, 13 May 2015 19:54:43 -0400
From Peter <p-santoro@sbcglobal.net>
Reply-To peter@psantoro.net
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0
MIME-Version 1.0
To python-list@python.org
Subject use of subprocess module inside generator
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.467.1431561493.12865.python-list@python.org> (permalink)
Lines 22
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1431561493 news.xs4all.nl 2935 [2001:888:2000:d::a6]:33938
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:90591

Show key headers only | View raw


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


Thread

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

csiph-web