How to avoid "f.close" (no parens) bug?

Nick Craig-Wood ncw at axis.demon.co.uk
Fri Feb 13 07:40:47 CET 2004


Peter Hansen <peter at engcorp.com> wrote:
>  Stephen Ferg wrote:
> > I've just spent several very frustrating hours tracking down a bug in
> > one of my programs.  The problem was that I was writing text to a
> > file, and when I was done I coded
> > 
> >    f.close
> > 
> > when I should have been coding
> > 
> >    f.close()
> > 
> > with the parentheses.
> 
>  One thing no one has done here yet is to ask about your background
>  in programming.

As a long time Perl programmer I've found myself making exactly that
mistake in Python.  In Perl method calls don't need parens if the call
doesn't take any arguments.

However I've also discovered pychecker ;-)

-- 
Nick Craig-Wood
ncw at axis.demon.co.uk



More information about the Python-list mailing list