simple python file writing question

Posted by aharon on Stack Overflow See other posts from Stack Overflow or by aharon
Published on 2011-01-01T23:41:51Z Indexed on 2011/01/01 23:53 UTC
Read the original article Hit count: 277

Filed under:
|

I'm learning Python, and have run into a bit of a problem. On my OSX install of Python 3.1, this happens in the console:

>>> filename = "test"
>>> reader = open(filename, 'r')
>>> writer = open(filename, 'w')
>>> reader.read()
''
>>> writer.write("hello world\n")
12
>>> reader.read()
''

And calling more test in BASH confirms that there is nothing in test. What's going on?

Thanks.

© Stack Overflow or respective owner

Related posts about python

Related posts about file