cannot write to file after close()

Fredrik Lundh fredrik at pythonware.com
Mon Sep 26 02:03:27 EDT 2005


Rainer Hubovsky wrote:

> Thank you Reinhold, that was the solution. But just because I am curious:
> what is this statement without the parentheses? After all it is a valid
> statement...

it's an expression that fetches the "close" method object, and throws
it away.  to see what it evaluates to, try running the code from the
interactive prompt (or add a print statement):

>>> f = open("foo", "w")
>>> f.close
<built-in method close of file object at 0x00836B20>

also see

    http://docs.python.org/ref/exprstmts.html
    http://docs.python.org/ref/attribute-references.html

</F>






More information about the Python-list mailing list