--- Dennis Lee Bieber <[EMAIL PROTECTED]> wrote:

> On Tue, 20 Nov 2007 01:16:53 -0800 (PST), Francesco Pietra
> <[EMAIL PROTECTED]> declaimed the following in comp.lang.python:
> 
> 
> > 
> > Now, "file .out" had "TER" inserted where I wanted. It might well be that
> it
> > was my incorrect use of your script.
> >
>       Well, it looks like, for purposes of demonstration, the supplied
> program is using "print" statements, which write to stdout. Not sure why
> you needed some sort of pipe/tee call, a simple "> new.output.file"
> redirection would have done.

I used "2>&1 | tee" because in many cases I want to check the screen. That in
ab initio computations, where solving the matrix allows ample vision of the
screen. I agree that for the scope of this python script it is redundant.
>   
> > (2) An extra line is inserted (which was not a problem of outputting the
> file
> > as I did), except between "TER" and the next line, as shown below:
> >
>       A result of using "print"... "print" adds a newline on the data --
> but ".readline()" does not /remove/ the newline on the input data -- so
> unmodified lines now end with two newlines..
> 
>       A common .strip() call on those lines might be sufficient...

It is indeed. After a few trials (I am quite new to Python and I rarely find
time for programming, but this attitude might change with Python), the
following script fulfills the scope:


f=open("output.pdb", "r")
for line in f:
        line=line.rstrip()
        if line:
                print line
f.close()



Thanks
francesco

> Or
> change the "print" statements to "sys.stdout.write(...)", and ensure
> that the "TER" is written /with/ a newline ("TER\n").
> -- 
>       Wulfraed        Dennis Lee Bieber               KD6MOG
>       [EMAIL PROTECTED]               [EMAIL PROTECTED]
>               HTTP://wlfraed.home.netcom.com/
>       (Bestiaria Support Staff:               [EMAIL PROTECTED])
>               HTTP://www.bestiaria.com/
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 



      
____________________________________________________________________________________
Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to