I know how to implement chmod u+w with the following code:
st = os.stat(dest_file)
os.chmod(dest_file, st.st_mode | stat.S_IWUSR)
But how about u-w?
st = os.stat(dest_file)
os.chmod(dest_file, st.st_mode & ~stat.S_IWUSR)
Explanation: ~ is the bitwise NOT operator, so a bitwise AND with ~stat.S_IWUSR clears the flag from st.st_mode.
To illustrate with imaginary values:
stat.S_IWUSR 00001000
~stat.S_IWUSR 11110111
s.st_mode 00101001
s.st_mode & ~stat.S_IWUSR 00100001