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

Paul Prescod paul at prescod.net
Thu Feb 12 12:26:35 EST 2004


Peter Hansen wrote:

>...
> I have *never* made this particular mistake in Python, nor, as 
> far as I can tell, have any of the several dozen Python programmers
> I've hired over the past few years (none of whom have VB backgrounds).

I make this mistake from time to time although by now I am more fluent 
in Python than any other language (and I was never fluent in a language 
where you called functions without parens). I also leave off trailing 
colons, quotes, etc. It is just laziness. I suspect I would never write:

   f.close

(it does stand out like a sore thumb)

But I might write

   foo(bar[0].doSomething)

I can usually diagnose these pretty quickly.

  Paul Prescod






More information about the Python-list mailing list