Let users execute but not view

Dave Kuhlman dkuhlman at rexx.com
Sun Jan 4 15:48:07 EST 2004


Florian Lindner wrote:

> Hi!
> I have a python script which should be executed my normal users
> but they should not be able to view the sourcecode. Setting
> permissions to x only does not help, the python interpreter can
> not read the file. How can I do that?

Compile it to a .pyc file and give that to your users instead of
the .py file.  You can use py_compile or compileall in the Python
standard libraries for this.

Note, however, that this does not protect you from the really
inquisitive or from malicious users and so on.  They could use
dis, for example, from the Python standard library to learn about
your code.

Dave

-- 
http://www.rexx.com/~dkuhlman
dkuhlman at rexx.com



More information about the Python-list mailing list