Path: csiph.com!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'elif': 0.04; 'sys': 0.05; 'message-id:@4ax.com': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'stdout': 0.09; 'python': 0.10; 'python.': 0.11; 'systems.': 0.11; 'question.': 0.13; 'suggest': 0.15; 'pipes': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'stdin': 0.16; 'true:': 0.16; '"you': 0.18; 'url:home': 0.18; '(in': 0.18; 'library': 0.20; 'windows': 0.20; '2015': 0.20; 'aug': 0.20; '%s"': 0.22; 'os,': 0.22; 'pipe': 0.22; 'pass': 0.22; 'import': 0.24; 'unix': 0.24; 'feature': 0.24; 'module': 0.25; 'header:X-Complaints-To:1': 0.26; 'handled': 0.29; 'random': 0.29; 'print': 0.30; 'another': 0.32; '-0700': 0.33; 'particular,': 0.33; 'skip:c 30': 0.35; 'something': 0.35; 'possible': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'charset:us-ascii': 0.37; 'manual': 0.38; 'mean': 0.38; 'to:addr:python.org': 0.40; 'called': 0.40; 'email addr:gmail.com': 0.62; 'more': 0.63; 'information': 0.63; '12:': 0.84; 'complex,': 0.84; 'too...': 0.84; 'dennis': 0.91; 'received:108': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dennis Lee Bieber Subject: Re: Pipes Date: Sun, 09 Aug 2015 14:17:57 -0400 Organization: IISS Elusive Unicorn References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: adsl-108-68-178-61.dsl.klmzmi.sbcglobal.net X-Newsreader: Forte Agent 6.00/32.1186 X-No-Archive: YES X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 147 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1439144297 news.xs4all.nl 2970 [2001:888:2000:d::a6]:54400 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:95199 On Sun, 9 Aug 2015 07:10:50 -0700 (PDT), rogerh906@gmail.com declaimed the following: >Just learning Python and have a question. > >Is it possible for Python to pass information to another program (in Windows), wait for that program to finish and then resume operating? > >It's called a pipe in Unix systems. > They are called pipes in Windows too... IF you mean the chaining of one process's stdout to another process's stdin -- and this feature is handled by the OS, not Python. -=-=-=-=- generator.py import random import sys for i in xrange(100): #yes, it's Python 2.7! sys.stdout.write("%s\n" % (random.randint(1, 6) + random.randint(1, 6)) ) -=-=-=-=- eater.py import sys while True: ln = sys.stdin.readline() if not ln: break v = int(ln.strip()) if v == 2: v = "snake-eyes" elif v == 12: v = "boxcars" print "You rolled %s" % v -=-=-=-=- console C:\Users\Wulfraed\Documents\Python Progs>generator | eater You rolled 6 You rolled 11 You rolled 6 You rolled 5 You rolled 11 You rolled 4 You rolled 4 You rolled 7 You rolled 3 You rolled boxcars You rolled 9 You rolled 8 You rolled 6 You rolled 7 You rolled 9 You rolled 7 You rolled 3 You rolled 8 You rolled 3 You rolled snake-eyes You rolled 6 You rolled 9 You rolled snake-eyes You rolled 7 You rolled 7 You rolled 7 You rolled 10 You rolled 7 You rolled 7 You rolled 7 You rolled 6 You rolled 3 You rolled 9 You rolled 4 You rolled 11 You rolled 6 You rolled 8 You rolled 7 You rolled 6 You rolled 10 You rolled 6 You rolled 8 You rolled 6 You rolled 9 You rolled 6 You rolled boxcars You rolled 8 You rolled 9 You rolled 9 You rolled 4 You rolled 7 You rolled 5 You rolled 8 You rolled 5 You rolled 11 You rolled 7 You rolled snake-eyes You rolled 8 You rolled snake-eyes You rolled 6 You rolled 9 You rolled 6 You rolled 6 You rolled 6 You rolled 10 You rolled 7 You rolled 6 You rolled 8 You rolled 7 You rolled 6 You rolled 6 You rolled 9 You rolled 5 You rolled 5 You rolled 4 You rolled 6 You rolled 4 You rolled 8 You rolled 8 You rolled snake-eyes You rolled 7 You rolled 5 You rolled 4 You rolled 7 You rolled 6 You rolled 7 You rolled 8 You rolled 8 You rolled 10 You rolled 9 You rolled 5 You rolled 10 You rolled 6 You rolled 8 You rolled 3 You rolled 5 You rolled 5 You rolled 4 You rolled 9 You rolled 8 C:\Users\Wulfraed\Documents\Python Progs> If you mean something more complex, then I suggest you read the library manual -- in particular, look for the module "subprocess" -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/