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

Isaac To kkto at csis.hku.hk
Thu Feb 12 20:46:17 EST 2004


>>>>> "Dang" == Dang Griffith <noemail at noemail4u.com> writes:

    Dang> I'm from a C background, and never made this particular mistake.

At least in GCC, the compiler will emit a warning when you do that (provided
that you use -Wall), telling you that you've generated a value without using
it.  This isn't possible in Python (or did I miss something?), so you never
know how many such subtle problem lies in your program, especially because
forgetting to close a file "normally" won't cause any visible problem (that
is, until you modify the same file somewhere elso and when the program
exits, half of your modifications are gone).

Regards,
Isaac.



More information about the Python-list mailing list