Re: stripping blanks

2006-05-02 Thread seeker
[EMAIL PROTECTED] wrote:
> hi
> i have a file test.dat eg
> 
> abcdefgh
> ijklmn
>  <-newline
> opqrs
> tuvwxyz
>   <---newline
> 
> I wish to print the contents of the file such that it appears:
> abcdefgh
> ijklmn
> opqrs
> tuvwxyz
> 
> here is what i did:
> f = open("test.dat")
> while 1:
> line = f.readline().rstrip("\n")
> if line == '':
> break
> #if not re.findall(r'^$',line):
> print line
> 
> but it always give me first 2 lines, ie
> abcdefgh
> ijklmn
> 
> What can i do to make it print all..?
> thanks
> 
Hi,

this should work better:


  f = open("test.dat")
  while 1:
  line = f.readline().rstrip("\n")
  if line == '':
  continue
  #if not re.findall(r'^$',line):
  print line
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: stripping blanks

2006-05-02 Thread seeker
[EMAIL PROTECTED] wrote:
> hi
> i have a file test.dat eg
> 
> abcdefgh
> ijklmn
>  <-newline
> opqrs
> tuvwxyz
>   <---newline
> 
> I wish to print the contents of the file such that it appears:
> abcdefgh
> ijklmn
> opqrs
> tuvwxyz
> 
> here is what i did:
> f = open("test.dat")
> while 1:
> line = f.readline().rstrip("\n")
> if line == '':
> break
> #if not re.findall(r'^$',line):
> print line
> 
> but it always give me first 2 lines, ie
> abcdefgh
> ijklmn
> 
> What can i do to make it print all..?
> thanks
> 

Last suggestion I made was bad. Here is the new one. Hopefully thats 
correct.

f = open("test.dat")
  for line in f:
 printLine = line.rstrip("\n")
 if not printLine:
 continue
 print printLine
-- 
http://mail.python.org/mailman/listinfo/python-list


the truth

2007-06-23 Thread the truth seeker
 Explore the greatest life of the most recognized man in
 the history of humanity.


http://mohammad.islamway.com

-- 
http://mail.python.org/mailman/listinfo/python-list