How do I make my python project files unreadable?

Question:

I have a question about Python projects. I have many projects structured like this:

Project Folder
| main.py
| resources
| | module1.py
| | module2.py

And I’m using this module1.py and module2.py in my main.py application and it all works perfectly fine. But I don’t know how to make these modules unreadable (hide them). When you see an application, it’s usually full of files that you can’t open and see what they are doing, that’s what I need. I don’t want people to be able to see what these files are doing.

Edit:
I need this because in one of my projects, I have a file of database connection that has to be in another file and I need a way to hide its information.

Asked By: BokiX

||

Answers:

Open the properties of the file, click on button Advanced and enable encryption for the file. This should help you

Answered By: Rami Smat

You can’t, basically. See these answers:

How to obfuscate Python code effectively?

How do I protect Python code from being read by users?

You can compile to bytecode (see first link for details), which makes docstrings and comments unrecoverable, but it can be undone to recover some variable names and the entire structure of your program. If all you need is to make it "kind of annoying" to reverse engineer your code, this might be good enough

Answered By: Matthew Tromp
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.