So for this I am trying to change only the group permissions for a file using chmod. I was able to add a executable permission to the group using
permissions = os.stat(filepath)
os.chmod(filepath, permissions.st_mode | stat.S_IXGRP)
I added the execute permission to the group successfully using this code but I don't know how to remove the permission if needed. Can anyone help me with this.