Hi Hugo,
many thanks for pointing that out. It all helps :)
Thanks again,
Nick .
On Tue, 2005-03-01 at 17:35 -0600, Hugo GonzÃlez Monteverde wrote:
> Everypne else has answered pretty muh about this. I just want to add
> that if you want to read noncanonically (less thana line ending in "\n"
Thanks to everyone who helped me with this.
It's certainly given me something to think about :)
Cheers
Nick .
On Tue, 2005-03-01 at 23:13 -0600, David Rock wrote:
> * Nick Lunt <[EMAIL PROTECTED]> [2005-03-01 22:23]:
> > On Tue, 2005-03-01 at 14:14 -0800, Sean Perry wrote:
> >
> > >
> > > unle
* Nick Lunt <[EMAIL PROTECTED]> [2005-03-01 22:23]:
> On Tue, 2005-03-01 at 14:14 -0800, Sean Perry wrote:
>
> >
> > unless you want the output for some other reason, a more idiomatic way
> > is:
> >
> > for line in sys.stdin.readlines():
> > # handle the line
> >
> > I tend to use xreadli
Everypne else has answered pretty muh about this. I just want to add
that if you want to read noncanonically (less thana line ending in "\n"
you'll have to do it char by char =( AFAIK, there's no way to redefine a
separator por readlines() (other than \n..)
Hugo
Nick Lunt wrote:
Hi folks,
I've
Hi,
On Mar 1, 2005, at 6:01 PM, Sean Perry wrote:
[EMAIL PROTECTED] wrote:
If I do:
$ ./produce.py | ./read.py
I get nothing for ten seconds, then I get the numbers 0 through 9,
one per line.
What am I missing?
From the python man page:
-u
Force stdin, stdout and stderr to be totally unbuffere
[EMAIL PROTECTED] wrote:
If I do:
$ ./produce.py | ./read.py
I get nothing for ten seconds, then I get the numbers 0 through 9, one per line.
What am I missing?
From the python man page:
-u
Force stdin, stdout and stderr to be totally unbuffered. On systems
where it matters, also put stdin, st
Quoting Max Noel <[EMAIL PROTECTED]>:
> UNIX philosophy is to have programs start acting as soon as possible
> -- in that case, as soon as the first line is available. You should be
> reading sys.stdin as an iterator (same thing you'd do for a file):
>
> import sys
> for line in sys.stdin:
On Wed, 2005-03-02 at 11:22 +1300, [EMAIL PROTECTED] wrote:
> Quoting Sean Perry <[EMAIL PROTECTED]>:
>
> > for line in sys.stdin.readlines():
> > # handle the line
> >
> > I tend to use xreadlines() which does not read the entire input at once.
>
> xreadlines() these days just does 'return sel
On Tue, 2005-03-01 at 22:20 +, Max Noel wrote:
> I don't think you are. You're using readlines(), which means your
> program won't execute until ps terminates.
> UNIX philosophy is to have programs start acting as soon as possible
> -- in that case, as soon as the first line is a
Quoting Sean Perry <[EMAIL PROTECTED]>:
> for line in sys.stdin.readlines():
> # handle the line
>
> I tend to use xreadlines() which does not read the entire input at once.
xreadlines() these days just does 'return self', I believe. File objects are
their own iterators; you can just do:
for
On Tue, 2005-03-01 at 14:14 -0800, Sean Perry wrote:
>
> unless you want the output for some other reason, a more idiomatic way
> is:
>
> for line in sys.stdin.readlines():
> # handle the line
>
> I tend to use xreadlines() which does not read the entire input at once.
> For stdin this
On Mar 1, 2005, at 22:08, Nick Lunt wrote:
The way I did this was to use sys.stdin.readlines() to get the output
from the pipe.
Here is the program:
[code]
import sys, glob
args = sys.stdin.readlines() # found on the net
pat = sys.argv[1]
for i in args:
if (i.find(pat) != -1):
Nick Lunt wrote:
The way I did this was to use sys.stdin.readlines() to get the output
from the pipe.
Here is the program:
[code]
import sys, glob
args = sys.stdin.readlines() # found on the net
pat = sys.argv[1]
for i in args:
if (i.find(pat) != -1):
print i,
[/code]
My que
Hi folks,
I've been pondering how to get python to read from a pipe outside of
itself, sort of.
For example I tried a simple python prog to do a grep, eg
# ps -e | myprog.py cron
would give this output
3778 ?00:00:00 crond
same as
# ps -e | grep cron
The way I did this was to use sy
14 matches
Mail list logo