Introduction To Python - Learn Python the hard way v2.0
voteup image
1

In ex. 16, We are overriding the file, if it exists, otherwise create new one and open it for writing. Then my question is What is the significance of using truncate there after opening it in write mode?

asked Nov 4, 2011

http://twitter.com/SacheenBirhade's image

http://twitter.com/SacheenBirhade

1 Answer:
voteup image
1

You are right, we do not need to use truncate when opening a file in w mode. In that mode the file is automatically truncated.

I think this exercise uses truncate and then adds a point in the extra credit if the participant finds out whether truncate is needed.

answered Nov 8, 2011

http://twitter.com/coding_insights's image

http://twitter.com/coding_insights

Provide an answer to this question.
This editor supports the markdown format. Please visit this page, If you are not familiar with Markdown.

Recent Course Updates: