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 the
> previous "if" condition. 
>  
> Notice that I wanted to comment out the #print line there.
> However I found problem with myfile.close(), with identation error.
> This error doesn't occur when commenting (#) is not in use.
>  
> Why so?  Is there away to do the commenting in correct way
> under this circumstances?

statement suites cannot be empty in Python (and comments don't count). 
to fix this, insert a "pass" statement:

     if m:
         print line,
     else:
         pass # print 'SPAM -- %s' % line

also see:

     http://effbot.org/pyref/pass.htm

</F>

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

Reply via email to