1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
barxatty [35]
3 years ago
10

Create a new folder in python and make it read only

Computers and Technology
1 answer:
igor_vitrenko [27]3 years ago
8 0
Making the file read-only will not allow the file to be rewritten again. For this, we need to modify the permissions of the file. To achieve this, we will make use of the os module in Python more specifically, the chmod() of the os module.

The coding part is extremely simple and will contain very few lines as we are not doing much but changing the permissions. Using the chmod(), we can change the mode of the path, setting it to any mode using the suitable flags from the stat module. Both these modules come inbuilt with Python and hence you need not install anything additionally.

The entire code to change the file to read-only is as follows;

import os
from stat import S_IREAD
# Replace the first parameter with your file name
os.chmod("sample.txt", S_IREAD)
.

You can verify if the code was executed correctly by checking the file’s permissions. To do that :

Right-click on the file and click properties.
Under the attributes section, you will find the read-only checkbox checked.
I hope you found this article useful and it helped you make a file read-only. You can do more than just making the file read-only by using the appropriate flag from the stat module.
You might be interested in
6.
HACTEHA [7]
Question 6 west Germany  
3 0
3 years ago
A video games sell for $59.99..
Neko [114]
Well, in texas the sales tax is 8.25%
So I'll use that example. <span>(A)
</span>sales tax = 8.25% of $59.99 = (8.25/100) * $59.99 = $4.95 <span>
(B)
</span>Price with tax = selling price + sales tax = $59.99 + $4.95 = $64.94 <span>
</span>
5 0
3 years ago
The border that defines the outer boundary of a shape or other object
Over [174]
The answer is outline
8 0
3 years ago
1. A(n)
Dennis_Churaev [7]

Answer:

1.Spelling checker


2. Order of mathematical operations .

3. Series  

4. Pick from list  

5. Sum Function


6. Active Cell  

7. cell


8. Accounting format


9. Format

Explanation:

4 0
3 years ago
The main goal of human relations is to A. help you relate better with others. B. make you an efficiency expert.
nirvana33 [79]
A. help you relate better with others.
8 0
3 years ago
Read 2 more answers
Other questions:
  • The main events of the civil war and reconstruction
    14·1 answer
  • If the user enters 26 what is output? _____________
    15·1 answer
  • What is the meaning of the title Two Kinds Of Stupid whose fault is it that Eduardo got in trouble
    8·1 answer
  • Insufficient vacuum will require the driver to _______________ to adequately activate the brakes?
    13·1 answer
  • Hide Time Remaining A
    11·1 answer
  • The network team has well established procedures to follow for creating new rules on the firewall. This includes having approval
    15·1 answer
  • Why would we need to consider implementing our business blockchain application not on Bitcoin but Ethereum?
    5·1 answer
  • FREEEEE 100 POINTS COME TAKE COME COME COME<br><br> only if u like da black panther
    8·2 answers
  • What do you think that private information like passwords, PIN numbers, will be guarded or shared with the public? Why?​
    13·1 answer
  • What are the task performed by window media player<br> ​
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!