Technical Answer - Protecting code in python

Tom Wright tew24 at
Wed Mar 21 14:44:58 CET 2007

flit wrote:
> 1 - There is a way to make some program in python and protects it? I
> am not talking about ultra hard-core protection, just a simple one
> that will stop 90% script kiddies.

Put it in an executable? It's more hidden than protected, but it will stop a
fair few non-experts.  I use and have been happy with pyinstaller, though
there are other options.  I use it more for ease of distribution to
non-techy users, but it's also a simply way to hide your code.

> 2 - If I put the code in web like a web service, how can I protect my
> code from being ripped? There is a way to avoid someone using my site
> and ripping the .py files?

Configure your web-server properly and it will never serve up the .py files,
only the results generated by them.  I've not done it with Python, but I
have set up a similar thing with Apache and XSLT where it will only give
the generated data, not the code which created it.  This is true even if
there's an error in the code - it will just give "HTTP 500 Internal Server
Error" and dump something a bit more useful to its error log.

I'm at CAMbridge, not SPAMbridge

More information about the Python-list mailing list