Problems with files

18 May, 2013

Evan writes:

I have a Windows 8 PC, and have installed Python 3.3 onto it, and worked my way up to the last part of chapter 9 in your book with no major problems. But now I am stuck in the last part of chapter 9. The first time I tried to save a notepad txt file to the C: location, access was denied, because the user account I was using was not the dominant user account. I fixed this by running the notepad as the administrator, and was able to save the txt file to the C: location. Opening and printing the contents of the txt file worked fine after that. My next problem (and still is a problem) was writing to the text file. The first error message said access was denied. I fixed this also by going to the administrator's user account and allowed the user settings I was working on to have almost complete control over all the C: location. Now when I try to write to the txt file, I get a different error: "OSError: [Errno 22] Invalid argument: 'c:\myfile.txt'. Please help me!

Hi Evan. The final error you're getting is generally caused by an invalid filename (for example, if you had two colons rather than one) - but I don't see that problem in the example you sent. So I'm not quite sure what's gone wrong there.

In terms of the example in the book, I've added a new entry in the errata (see the section Page 123). The directions should instead tell you to save the file to your user directory - something like: c:\\Users\\Evan - rather than to c:\. Check the errata and hopefully that should work for you.