Use os.stat()
to get the current permissions, use |
to OR the bits together, and use os.chmod()
to set the updated permissions.
Example:
import os
import stat
st = os.stat('somefile')
os.chmod('somefile', st.st_mode | stat.S_IEXEC)
More Related Contents:
- Evaluating a mathematical expression in a string
- How to move a file in Python?
- Are for-loops in pandas really bad? When should I care?
- retrieve links from web page using python and BeautifulSoup [closed]
- Change ChromeOptions in an existing webdriver
- Environment variable differences when using Paramiko
- How to load and play a video in pygame
- How to convert webpage into PDF by using Python
- Find maximum value of a column and return the corresponding row values using Pandas
- Generating matplotlib graphs without a running X server [duplicate]
- How to get item’s position in a list?
- Timeout for python requests.get entire response
- Can’t install new packages for Python (Python 3.9.0, Windows 10)
- How to upload a file to directory in S3 bucket using boto
- How to convert column with dtype as object to string in Pandas Dataframe [duplicate]
- Cannot redirect output when I run Python script on Windows using just script’s name
- Format numbers to strings in Python
- Dynamically add/create subplots in matplotlib
- How to remove duplicate lists in a list of list? [duplicate]
- top values from dictionary
- Convert column to row in Python Pandas
- Detect text area in an image using python and opencv
- How do you check in python whether a string contains only numbers?
- Read a base 64 encoded image from memory using OpenCv python library
- Selecting a value from a drop-down option using selenium python
- How do I count the values from a pandas column which is a list of strings?
- Is there a python module to solve linear equations?
- Putting many python pandas dataframes to one excel worksheet
- Real-time intercepting of stdout from another process in Python
- Python 4D linear interpolation on a rectangular grid