4

I'm trying to send a python script I wrote on my Mac to my friends. Problem is, I don't want to send them the code that they can edit. How can I have my script change from an editable text file, to a program that you click to run?

2
  • 1
    Do your friends have Windows, Mac, or Linux machines? Commented Mar 3, 2012 at 2:38
  • You can wrap up the interpreter and the source code into an executable. But they will still be able to access the source code if they want to! Commented Mar 3, 2012 at 6:05

5 Answers 5

3

There is an equivalent to py2exe called py2app. I never tried it but there is a lot of good comments. It is available on macport and the tutorial seems pretty simple (for simple cases at least :) ).

Sign up to request clarification or add additional context in comments.

Comments

2

if you import it (from the shell, or from another python app), it should create a .pyc file, which is compiled python. You shouldn't be able to edit it through a text editor.

Example:

#test.py
print "Hello, world."

# python shell
>>>import test

2 Comments

Provided everybody has identical versions of things. Otherwise the compiled file may or may not work.
True, but this is the best solution. Have any other ideas?
0

If your friends are on windows you could use py2exe, but if they're on Mac I'm not sure there's an equivalent. Either way, compiling like that breaks cross platform compatability, which is the whole point of an interpreted language really...

Python just isn't really set up to hide code like that, it's against it's philosophy as far as I can tell.

Comments

0

Well since you're on a mac you could compile using py2app it will compile your code in a similar way to py2exe but for OSX.

Otherwise you could always transfer it to a windows computer and just use py2exe.

Comments

-1

You could try py2exe (http://www.py2exe.org/) since it compiles your code into an exe file, they should have a hell of a time trying to decompose it.

1 Comment

I'm on a mac. Would be great if I had a PC. Heard some nice things about that.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.