How to avoid "f.close" (no parens) bug?
Skip Montanaro
skip at pobox.com
Wed Feb 11 12:15:21 EST 2004
Facundo> But, what's the point to have a...
Facundo> t.spanish_inquisition
Facundo> ...alone?
You might want it precisely for its side effects.
Facundo> What I'm trying to say is: If you're not executing any code (no
Facundo> function call) and you're not doing any assingment, what's the
Facundo> point of that line?
There is none, but the Python compiler doesn't know that when it compiles
the code, so it's not reasonable for it to issue a warning. The OP
indicated he had a hard time discovering
f.close
instead of the
f.close()
which he had intended. A couple of us chimed in that he could detect the
problem with pychecker. That pychecker can only say
f.close appears to have no effect
is precisely because it can't easily (or at all?) tell whether or not it's
of any use, even though it has a more global view of the run-time
environment than the compiler does (which only considers a single module in
isolation).
Skip
More information about the Python-list
mailing list