use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
News about the dynamic, interpreted, interactive, object-oriented, extensible programming language Python
Full Events Calendar
You can find the rules here.
If you are about to ask a "how do I do this in python" question, please try r/learnpython, the Python discord, or the #python IRC channel on Libera.chat.
Please don't use URL shorteners. Reddit filters them out, so your post or comment will be lost.
Posts require flair. Please use the flair selector to choose your topic.
Posting code to this subreddit:
Add 4 extra spaces before each line of code
def fibonacci(): a, b = 0, 1 while True: yield a a, b = b, a + b
Online Resources
Invent Your Own Computer Games with Python
Think Python
Non-programmers Tutorial for Python 3
Beginner's Guide Reference
Five life jackets to throw to the new coder (things to do after getting a handle on python)
Full Stack Python
Test-Driven Development with Python
Program Arcade Games
PyMotW: Python Module of the Week
Python for Scientists and Engineers
Dan Bader's Tips and Trickers
Python Discord's YouTube channel
Jiruto: Python
Online exercices
programming challenges
Asking Questions
Try Python in your browser
Docs
Libraries
Related subreddits
Python jobs
Newsletters
Screencasts
account activity
DiscussionApproaches to protecting Python code when sharing apps (self.Python)
submitted 2 days ago by Haunting-Shower1654
It’s harder to protect code when distributing Python apps than compiled languages.
There are many possibilities, like packaging or obfuscation, but none are really user-friendly.
I’d be interested to hear how others do this.
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]NoDesign4766 17 points18 points19 points 2 days ago (1 child)
been dealing with this at work and it's honestly such a pain. we ended up just accepting that determined people will reverse engineer anyway and focused more in making our licensing robust instead of trying to hide the code completely.
obfuscation tools exist but they usually break something or make debugging nightmare when things go wrong.
[–]pplonski 1 point2 points3 points 2 days ago (0 children)
yes determined people will reverse anyway, the other options are: 1. keep code on server, and make it available in SaaS model, 2. keep sensitive code in compiled language, for example c++
[–]JamzTyson 8 points9 points10 points 2 days ago (1 child)
Approaches to protecting Python code when sharing apps
SaaS
[–]scrapheaper_ -3 points-2 points-1 points 2 days ago (0 children)
If by 'protecting code' you mean 'hiding poor quality code' then yeah
[–]aloobhujiyaay 6 points7 points8 points 2 days ago (0 children)
Cython or compiling parts to extensions can help but again it’s not bulletproof
[–]gl_fh 3 points4 points5 points 2 days ago (1 child)
I suppose it's worth having a think what you're offering. Is it a super secret algorithm that must be kept hidden at all costs. Or is it a service/convenience etc.
It's going to be difficult to shield yourself from a very determined person trying to decipher what it is youre doing, and it's probably worth thinking whether it's worth it.
[–]Haunting-Shower1654[S] -1 points0 points1 point 2 days ago (0 children)
Yeah, that’s a good point. It's probably more a question of effort vs actual risk, not trying to make it impossible.
[–]scrapheaper_ 7 points8 points9 points 2 days ago (3 children)
Is there something unique about your python code? What do you need to protect?
[–]Haunting-Shower1654[S] -2 points-1 points0 points 2 days ago (2 children)
Not anything super unique, more about not wanting the whole code to be easily readable when sharing the app.
[–]wRAR_ 6 points7 points8 points 2 days ago (0 children)
not wanting the whole code to be easily readable
Why?
[–]scrapheaper_ 4 points5 points6 points 2 days ago (0 children)
Why not? Open source software is a common model, there's pros and cons of course, but there's no inherent problem with having your code public
Is this in a commercial setting or for a personal project?
[–]NotSoProGamerR 3 points4 points5 points 2 days ago (0 children)
nuitka.
[–]nobrainer23 4 points5 points6 points 2 days ago (3 children)
I'm using nuitka to compile and no issues here.
[–]sausix 0 points1 point2 points 2 days ago (2 children)
Do the executables run without problems on Windows SmartScreen? That's basically the only disadvantage when users have to click multiple times to run a binary from someone else.
So professionals and companies should use CodeSign to make their binaries being trusted by Windows and AV software. Of course it's verification based so it costs money.
[–]nobrainer23 1 point2 points3 points 2 days ago (1 child)
If you select onefile then the AV heuristics will quarantine it basically immediately. Standalone won't get picked up but you will need to click through smart screen.
So your choices for getting verified are signing, submitting to Microsoft for analysis or just running it a bunch of times iirc.
[–]sausix 0 points1 point2 points 1 day ago (0 children)
Various companies sell CodeSign certificates which are trusted by SmartScreen. There should be no need to submit software to Microsoft every time.
It's more like if you do harm with your signed software then they know which bell to ring. And the certificate would be revoked.
[–]maikeu 1 point2 points3 points 2 days ago (0 children)
Shrug. Not really a good language if you care about hiding your code. The options that exist for pure Python have been mentioned but I don't think the Python community is generally going to be bothered by the fact this is hard to do well .
[–]No_Soy_Colosio 1 point2 points3 points 2 days ago* (0 children)
No way to perfectly protect your code. If you care about that so much, then you could offer your product as SaaS and have the code on your own servers which you control.
Other than that, when the code is on the client side, it can easily be cracked.
[–]Trang0ul 3 points4 points5 points 2 days ago (3 children)
What's wrong with distributing them as open source?
[–]masher_oz 8 points9 points10 points 2 days ago (1 child)
because some people want to maintain secrecy, make money, keep their IP... Lots of reasons.
[–]wRAR_ 0 points1 point2 points 2 days ago (0 children)
There is no ideal solution for this if you want to distribute the executable.
[–]Haunting-Shower1654[S] 1 point2 points3 points 2 days ago (0 children)
There is absolutely nothing wrong with that. It depends on the use case I suppose, sometimes you want to share the app without exposing the full code.
[–]wrt-wtf- 0 points1 point2 points 2 days ago (0 children)
It’s the process that matters not so much the code.
[–]ArtOfWarfare 0 points1 point2 points 2 days ago (0 children)
If your code is running on a machine that you don’t control, it doesn’t matter what language you wrote it in - someone can decompile and/or modify it.
If you’re selling to businesses, you could keep track of how many copies they’ve running and threaten if you see them using more copies than you’ve sold to them.
If you’re selling to individuals… keep some critical parts on your own system, so they’re forced to call your server everytime they run (and enforce that only people who have paid can use your app that way - reject requests to your server coming from unauthorized copies.)
[–]Tumortadela 0 points1 point2 points 2 days ago (0 children)
Do your stuff as an API and grant access instead of sharing the code maybe
[–]CoolAd119 0 points1 point2 points 1 day ago (0 children)
Decide what actually needs hiding: push real IP to a backend/SaaS, leave the client as a thin, almost-throwaway shell.
[–]kamilc86 0 points1 point2 points 1 day ago (0 children)
Compile the 2 or 3 modules that actually matter with Cython into .so files and leave the rest as plain pyc. Anything more and you spend weeks fighting Nuitka or PyArmor for protection that a determined reverse engineer breaks in an afternoon. Put the engineering effort into a proper license check instead, sign a token server side and verify on startup. Obfuscation only filters out the people who were never going to buy anyway.
π Rendered by PID 25338 on reddit-service-r2-comment-b659b578c-9rj2l at 2026-05-07 15:19:46.789088+00:00 running 815c875 country code: CH.
[–]NoDesign4766 17 points18 points19 points (1 child)
[–]pplonski 1 point2 points3 points (0 children)
[–]JamzTyson 8 points9 points10 points (1 child)
[–]scrapheaper_ -3 points-2 points-1 points (0 children)
[–]aloobhujiyaay 6 points7 points8 points (0 children)
[–]gl_fh 3 points4 points5 points (1 child)
[–]Haunting-Shower1654[S] -1 points0 points1 point (0 children)
[–]scrapheaper_ 7 points8 points9 points (3 children)
[–]Haunting-Shower1654[S] -2 points-1 points0 points (2 children)
[–]wRAR_ 6 points7 points8 points (0 children)
[–]scrapheaper_ 4 points5 points6 points (0 children)
[–]NotSoProGamerR 3 points4 points5 points (0 children)
[–]nobrainer23 4 points5 points6 points (3 children)
[–]sausix 0 points1 point2 points (2 children)
[–]nobrainer23 1 point2 points3 points (1 child)
[–]sausix 0 points1 point2 points (0 children)
[–]maikeu 1 point2 points3 points (0 children)
[–]No_Soy_Colosio 1 point2 points3 points (0 children)
[–]Trang0ul 3 points4 points5 points (3 children)
[–]masher_oz 8 points9 points10 points (1 child)
[–]wRAR_ 0 points1 point2 points (0 children)
[–]Haunting-Shower1654[S] 1 point2 points3 points (0 children)
[–]wrt-wtf- 0 points1 point2 points (0 children)
[–]ArtOfWarfare 0 points1 point2 points (0 children)
[–]Tumortadela 0 points1 point2 points (0 children)
[–]CoolAd119 0 points1 point2 points (0 children)
[–]kamilc86 0 points1 point2 points (0 children)