Problem Commenting within Filehandle Iteration
fredrik at pythonware.com
Thu Oct 26 10:16:23 CEST 2006
Wijaya Edward wrote:
> if m:
> print line,
> #print 'SPAM -- %s' % line
> 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:
pass # print 'SPAM -- %s' % line
More information about the Python-list