Reputation: 127
I am working on a small python3 project which is a TKinter GUI program, how I can restrict users from deleting the associated files like sqlite3 DB, templates, html etc. until the python script is running. I tried some solution of locking the file into read only which restricts users to delete files but same time it became Un useful for my python script. Is there any way i can keep the file read/write for python script but read only for user who is using the program so files cannot be removed.
Upvotes: 1
Views: 108
Reputation: 38
If you open files with with open()
, they will be marked as "used" by Python
, and you can't delete them.
Example:
import asyncio
async def main():
with open(r".\fox.txt"):
await asyncio.sleep(1000)
if __name__ == "__main__":
asyncio.run(main())
Upvotes: 0