Re: NEWBIE: Tokenize command output

2006-05-12 Thread bruno at modulix
Duncan Booth wrote: > bruno at modulix wrote: > > >>>Otherwise, just to be informed, what advantage does rstrip() have over >>>[:-1] (if the two cases are considered uneventfully the same)? >> >>1/ if your line doesn't end with a newline, line[:-1] will still remove >>the last caracter. >> > > I

Re: NEWBIE: Tokenize command output

2006-05-12 Thread Duncan Booth
bruno at modulix wrote: >> Otherwise, just to be informed, what advantage does rstrip() have over >> [:-1] (if the two cases are considered uneventfully the same)? > > 1/ if your line doesn't end with a newline, line[:-1] will still remove > the last caracter. > In particular, if the last line o

Re: NEWBIE: Tokenize command output

2006-05-12 Thread Tim Chase
> I reeducated my fingers after having troubles with huge files !-) I'll keep it in mind...the prospect of future trouble with large files is a good kick-in-the-pants to remember. >>Otherwise, just to be informed, what advantage does rstrip() have over >>[:-1] (if the two cases are considered un

Re: NEWBIE: Tokenize command output

2006-05-12 Thread bruno at modulix
Tim Chase wrote: >>> starLines = [line for line in p.readlines() if line.startswith("*")] >> >> >> files are iterators, so no need to use readlines() (unless it's an old >> Python version of course): >> >> starLines = [line for line in p if line.startswith("*")] > > > Having started with some old

Re: NEWBIE: Tokenize command output

2006-05-12 Thread Tim Chase
>>starLines = [line for line in p.readlines() if line.startswith("*")] > > files are iterators, so no need to use readlines() (unless it's an old > Python version of course): > > starLines = [line for line in p if line.startswith("*")] Having started with some old Python, it's one of those thin

Re: NEWBIE: Tokenize command output

2006-05-12 Thread bruno at modulix
Tim Chase wrote: (snip) > starLines = [line for line in p.readlines() if line.startswith("*")] files are iterators, so no need to use readlines() (unless it's an old Python version of course): starLines = [line for line in p if line.startswith("*")] > or you may optionally want to prune of the "

Re: NEWBIE: Tokenize command output

2006-05-11 Thread Steven Bethard
Lorenzo Thurman wrote: > This is what I have so far: > > // > #!/usr/bin/python > > import os > > cmd = 'ntpq -p' > > output = os.popen(cmd).read() > // > > The output is saved in the variable 'output'. What I need to do next is > select the line from that output that starts with the '*' [sni

Re: NEWBIE: Tokenize command output

2006-05-11 Thread Tim Chase
Lorenzo Thurman wrote: > This is what I have so far: > > // > #!/usr/bin/python > > import os > > cmd = 'ntpq -p' > > output = os.popen(cmd).read() > // > > The output is saved in the variable 'output'. What I need to do next is > select the line from that output that starts with the '*' Wel

NEWBIE: Tokenize command output

2006-05-11 Thread Lorenzo Thurman
This is what I have so far: // #!/usr/bin/python import os cmd = 'ntpq -p' output = os.popen(cmd).read() // The output is saved in the variable 'output'. What I need to do next is select the line from that output that starts with the '*' remote refid st t when poll reach