How to avoid "f.close" (no parens) bug?
nick at craig-wood.com
Mon Nov 14 11:30:07 CET 2005
Peter <peter at commonlawgov.org> wrote:
> First off, please explain what you are talking about better next time.
> Second, What on earth are you talking about?
> "f" is a file object, correct?
> Are you trying to close a file by typing f.close or is the file closing
> when you type f.close?
I would guess that this person is coming to python from perl. In
perl, you are allowed to miss the parens off a method call if it takes
no arguments, so f.close is equivalent to f.close().
I used to make this mistake all the time. However it is one pychecker
catches, so install pychecker and run it on all your programs is the
Nick Craig-Wood <nick at craig-wood.com> -- http://www.craig-wood.com/nick
More information about the Python-list