Thursday, October 11, 2012

How to Create an Executable Zip File

Python has the ability to execute a zip file that contains Python files. This makes it very handy to create an executable zip file. Here's an example how to do it.
#!/usr/bin/env python

def say_something(): print "Hello World"
def main(): say_something()
#!/usr/bin/env python

import test

if __name__ == "__main__": test.main()
The must be in the root directory of the zip file.

Zip all the Python files so that it looks like below. We don't need to use .zip extension, we can name it anything we want.
To execute it:
and you will see the output as
Hello World

No comments:

Post a Comment