Getting TypeError in Changing file permissions

P

Pranav Bagora

Hello ,
i am trying to change mode of files using the
os.chmod()function. But i am getting an error

" os.chmod(outfile,0700)
TypeError: coercing to Unicode: need string or buffer,
file found"

Please Help,
Pranav

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
 
B

Benjamin Niemann

Pranav said:
Hello ,
i am trying to change mode of files using the
os.chmod()function. But i am getting an error

" os.chmod(outfile,0700)
TypeError: coercing to Unicode: need string or buffer,
file found"

Looks as if your are using a file object (that you got from an open() call)
as the first parameter. What you need is a string with the path to the
file.
 
P

Peter Hansen

Benjamin said:
Looks as if your are using a file object (that you got from an open() call)
as the first parameter. What you need is a string with the path to the
file.

Which this should do:

os.chmod(outfile.name, 0700)

-Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top