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


Groups > comp.lang.python > #95199

Re: Pipes

From Dennis Lee Bieber <wlfraed@ix.netcom.com>
Subject Re: Pipes
Date 2015-08-09 14:17 -0400
Organization IISS Elusive Unicorn
References <d6a3dfe4-8389-463b-ac66-a93f14a91a5e@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.13.1439144297.3627.python-list@python.org> (permalink)

Show all headers | View raw


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/

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Pipes rogerh906@gmail.com - 2015-08-09 07:10 -0700
  Re: Pipes Ian Kelly <ian.g.kelly@gmail.com> - 2015-08-09 11:13 -0600
  Re: Pipes rogerh906@gmail.com - 2015-08-09 10:39 -0700
    Re: Pipes Ian Kelly <ian.g.kelly@gmail.com> - 2015-08-09 11:52 -0600
    Re: Pipes Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-08-09 19:34 +0100
  Re: Pipes rogerh906@gmail.com - 2015-08-09 10:55 -0700
    Re: Pipes Emile van Sebille <emile@fenx.com> - 2015-08-09 11:51 -0700
    Re: Pipes alister <alister.nospam.ware@ntlworld.com> - 2015-08-09 18:55 +0000
    Re: Pipes Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-08-09 16:43 -0400
    Re: Pipes Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-08-09 22:18 +0100
    Re: Pipes Cameron Simpson <cs@zip.com.au> - 2015-08-10 08:27 +1000
    RE: Pipes "Clayton Kirkwood" <crk@godblessthe.us> - 2015-08-09 17:44 -0700
    Re: Pipes Chris Angelico <rosuav@gmail.com> - 2015-08-10 20:50 +1000
    Re: Pipes Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-08-10 14:44 +0100
      Re: Pipes rogerh906@gmail.com - 2015-08-10 07:05 -0700
        Re: Pipes Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-08-10 15:36 +0100
  Re: Pipes Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-08-09 14:17 -0400
  Re: Pipes "E.D.G." <edgrsprj@ix.netcom.com> - 2015-08-10 15:43 -0500
    Re: Pipes Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-08-10 22:59 +0100
    Re: Pipes Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-08-10 18:41 -0400
    Re: Pipes Larry Hudson <orgnut@yahoo.com> - 2015-08-10 21:48 -0700
    Re: Pipes Laura Creighton <lac@openend.se> - 2015-08-11 11:07 +0200
    Re: Pipes Laura Creighton <lac@openend.se> - 2015-08-11 11:58 +0200
    Re: Pipes Tim Golden <mail@timgolden.me.uk> - 2015-08-11 11:15 +0100

csiph-web