Re: Problem Commenting within Filehandle Iteration

2006-10-26 Thread Ben Finney
Fredrik Lundh <[EMAIL PROTECTED]> writes: > Ben Finney wrote: > > > My preferred answer: > > > > if m: > > print line, > > > > and get the lines back again later from your version control system. > > switching debugging statements on and off by rolling back to an > earlier release st

Re: Problem Commenting within Filehandle Iteration

2006-10-26 Thread Fredrik Lundh
Ben Finney wrote: > My preferred answer: > > if m: > print line, > > and get the lines back again later from your version control system. switching debugging statements on and off by rolling back to an earlier release strikes me as a somewhat misguided use of version control. --

Re: Problem Commenting within Filehandle Iteration

2006-10-26 Thread Ben Finney
Wijaya Edward <[EMAIL PROTECTED]> writes: > if m: > print line, > else: > #print 'SPAM -- %s' % line Simple answer: if m: print line, # else: # print 'SPAM' My preferred answer: if m: print line, and get the lines back again later f

Re: Problem Commenting within Filehandle Iteration

2006-10-26 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Wijaya Edward wrote: > if m: > print line, > else: > #print 'SPAM -- %s' % line > myfile.close() > > […] > > Notice that I wanted to comment out the #print line there. > However I found problem with myfile.close(), with identation error. > This erro

Re: Problem Commenting within Filehandle Iteration

2006-10-26 Thread Fredrik Lundh
Wijaya Edward wrote: > if m: > print line, > else: > #print 'SPAM -- %s' % line > myfile.close() > > Sometime while developing/debugging the code we usually > put in such situation. Where expression under "else" > is not yet supplied, yet we would like see the printout of

Problem Commenting within Filehandle Iteration

2006-10-26 Thread Wijaya Edward
Hi all, I have the following code: import sys import re ham_count = 0 spam_count = 0 myfile = open('full/index') for line in myfile.readlines(): p = re.compile('ham') m = p.match(line) if m: print line, else: #print