Why Can't I Delete a File I Created with Win XP?

John Machin sjmachin at lexicon.net
Sat Dec 5 17:42:33 EST 2009


On Dec 6, 2:46 am, "W. eWatson" <wolftra... at invalid.com> wrote:

[snip]

>          f = file( s, "wb" )
>          if not f:
>              self.LogError( "File creation error 1" )
>              return False

Either you are shadowing the built-in function file() or you haven't
tested this code ... file() aka open() returns a file object (which
cannot have a "false" value) or it raises an exception; the
self.LogError() call can never be executed.


> I caused the redundancy by just changing the meaning of s with a new
> statement below it. I should have commented the first one out. Yeah, I
> probably screwed up here and should have and,for purposes of debugging,
> just used another file name like s="ADATAFILE2009_mmdd.txt", which does
> not exist at this point of the coding stage. So I should have produced
> Analysis\ADATAFILE2009_mmdd.txt. If I had done that then I would have
> ended up with an empty file in the Analysis folder.

Ever heard the phrase "need to know"?

> However, even at
> that, why can't I delete this empty file called Analysis?

Are you trying to delete the file from another command window while
Python is paused at the interactive prompt? In any case describe how
you are trying to delete the file. Fire up another command window, cd
to whatever is the current working directory for your script, do a dir
command, and copy/paste the RELEVANT parts (including all directory
names). Please don't top-post, and before you hit the send button,
please delete any text that is more appropriate to your memoirs than a
problem description.



More information about the Python-list mailing list