classification
Title: os.remove()method document error
Type: resource usage Stage:
Components: Documentation Versions: Python 2.5
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: georg.brandl Nosy List: amaury.forgeotdarc, benjamin.peterson, facundobatista, georg.brandl, zkfarmer
Priority: normal Keywords:

Created on 2008-07-28 00:40 by zkfarmer, last changed 2008-08-04 10:01 by georg.brandl. This issue is now closed.

Files
File name Uploaded Description Edit
unnamed zkfarmer, 2008-07-28 09:55
unnamed zkfarmer, 2008-07-28 13:35
unnamed zkfarmer, 2008-07-28 14:07
unnamed zkfarmer, 2008-08-04 09:19
Messages (11)
msg70334 - (view) Author: 香槟酒 (zkfarmer) Date: 2008-07-28 00:40
in Python 2.5 document, os.remove() explain: On Windows, attempting to
remove a file that is in use causes an exception to be raised. but, i
run it in IDLE.it deletes my file that in use without any exception.
msg70335 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2008-07-28 01:35
What do you mean by "in use"?
msg70339 - (view) Author: 香槟酒 (zkfarmer) Date: 2008-07-28 09:55
yes, i use this method,but actually the result don't agree with the Python's
manual. my OS is windows xp and version is simplified chinese!

2008/7/28 Benjamin Peterson <report@bugs.python.org>

>
> Benjamin Peterson <musiccomposition@gmail.com> added the comment:
>
> What do you mean by "in use"?
>
> ----------
> nosy: +benjamin.peterson
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue3455>
> _______________________________________
>
msg70340 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2008-07-28 10:02
There seems to be some misunderstanding.

zkfarmer, you said: "it deletes my file that in use without any exception."
Can you explain this sentence? How is your file "in use"?
msg70344 - (view) Author: Facundo Batista (facundobatista) * (Python committer) Date: 2008-07-28 12:15
zkfarmer, please try the following from your IDLE:

>>> myfilename = r"c:\tmp\test.txt"
>>> fh = open(myfilename, "w")
>>> fh.write("test\n")
>>> fh.close()
>>> fh = open(myfilename)
>>> import os
>>> os.remove(myfilename)

Traceback (most recent call last):
  File "<pyshell#6>", line 1, in <module>
    os.remove(myfilename)
WindowsError: [Error 32] The process cannot access the file because it
is being used by another process: 'c:\\tmp\\test.txt'
>>> 

...and copy here what happened.

Thanks!
msg70348 - (view) Author: 香槟酒 (zkfarmer) Date: 2008-07-28 13:35
Thank you for your reply.I mean I used gvim to open a file. the Python
manual did not specify how to use a file, but said that if a file is to be
used, the deletion of the file will be exception to be raise.so when I use
gvim to open a file, then run os.remove () method to remove the file, the
file is deleted, and no exception to be raise.

2008/7/28 Facundo Batista <report@bugs.python.org>

>
> Facundo Batista <facundo@taniquetil.com.ar> added the comment:
>
> zkfarmer, please try the following from your IDLE:
>
> >>> myfilename = r"c:\tmp\test.txt"
> >>> fh = open(myfilename, "w")
> >>> fh.write("test\n")
> >>> fh.close()
> >>> fh = open(myfilename)
> >>> import os
> >>> os.remove(myfilename)
>
> Traceback (most recent call last):
>  File "<pyshell#6>", line 1, in <module>
>    os.remove(myfilename)
> WindowsError: [Error 32] The process cannot access the file because it
> is being used by another process: 'c:\\tmp\\test.txt'
> >>>
>
> ...and copy here what happened.
>
> Thanks!
>
> ----------
> nosy: +facundobatista
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue3455>
> _______________________________________
>
msg70349 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2008-07-28 13:52
Editors usually don't cause the file to be "in use." "In use" would 
mean that the file was being held open by a program. Editors only do 
that when they are opening or saving a file.
msg70350 - (view) Author: 香槟酒 (zkfarmer) Date: 2008-07-28 14:07
Thanks, you are right, I am wrong, I think that is the use of editing, so I
made a mistake.

2008/7/28 Benjamin Peterson <report@bugs.python.org>

>
> Benjamin Peterson <musiccomposition@gmail.com> added the comment:
>
> Editors usually don't cause the file to be "in use." "In use" would
> mean that the file was being held open by a program. Editors only do
> that when they are opening or saving a file.
>
> ----------
> resolution:  -> invalid
> status: open -> closed
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue3455>
> _______________________________________
>
msg70368 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2008-07-28 19:42
Can a file be "in use" other than being opened? If not, wouldn't be
"opened" be a better wording?
msg70691 - (view) Author: 香槟酒 (zkfarmer) Date: 2008-08-04 09:19
I can't understand you. Could you explain more?

2008/7/29 Georg Brandl <report@bugs.python.org>

>
> Georg Brandl <georg@python.org> added the comment:
>
> Can a file be "in use" other than being opened? If not, wouldn't be
> "opened" be a better wording?
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue3455>
> _______________________________________
>
msg70693 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2008-08-04 10:01
Well, you seemed to be misled by the wording "in use". Therefore, I
propose to change "in use" to "opened", but only if "in use" always
means "opened".
History
Date User Action Args
2008-08-04 10:01:43georg.brandlsetmessages: + msg70693
2008-08-04 09:19:06zkfarmersetfiles: + unnamed
messages: + msg70691
2008-07-28 19:42:54georg.brandlsetmessages: + msg70368
2008-07-28 14:07:10zkfarmersetfiles: + unnamed
messages: + msg70350
2008-07-28 13:52:56benjamin.petersonsetstatus: open -> closed
resolution: not a bug
messages: + msg70349
2008-07-28 13:35:35zkfarmersetfiles: + unnamed
messages: + msg70348
2008-07-28 12:15:12facundobatistasetnosy: + facundobatista
messages: + msg70344
2008-07-28 10:02:54amaury.forgeotdarcsetnosy: + amaury.forgeotdarc
messages: + msg70340
2008-07-28 09:55:36zkfarmersetfiles: + unnamed
messages: + msg70339
2008-07-28 01:35:47benjamin.petersonsetnosy: + benjamin.peterson
messages: + msg70335
2008-07-28 00:41:46zkfarmersettype: performance -> resource usage
2008-07-28 00:40:08zkfarmercreate