[python-win32] [Errno 2] No such file or directory:

Gabriel Genellina gagsl-p32 at yahoo.com.ar
Thu Jul 27 04:08:32 CEST 2006


At Wednesday 26/7/2006 16:33, Ahmed, Shakir wrote:

>I am trying to change the file permission for all of the files in a
>directory but getting errno 2, the code is as follows, any help is
>highly appreciated. I am using pythonwin version 2.1
>
>
>
>permission.py
>
>for fl in os.listdir("V:\\data\\tst\\mdb"):
>
>
>     import os
>
>
>     def unicode_test(fl):
>         try:
>             f = file(fl, 'w')
>             f.close()
>         except IOError, e:
>             print e
>             return
>     try:
>         os.chmod(fl, -0777)
>     except OSError, e:
>         print e
>
>
>====
>The error I am getting :
>
> >>> [Errno 2] No such file or directory: 'gend_taskstatus.mdb'
>[Errno 2] No such file or directory: 'str.mdb'

os.listdir() returns the names *without* path. Use os.path.join to 
join path+name.
-0777 looks like Unix permission bits (negative?), but a path with \\ 
is strange...
The enclosed function unicode_test is useless.
And, the import statement usually is located at the top of the module.



Gabriel Genellina
Softlab SRL 


	
	
		
__________________________________________________
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas



More information about the Python-win32 mailing list