Thanks, but I really don't want to use py2exe as my target machines are not Windows. They are Linux and OS-X.
I assume that somewhere there is a solution that is able to run on anything python runs on, which includes microcontrollers that
don't even run an operating system.
Which raises the question, for me: what is a module, and how is it named _main_?
Is a module just a source file?
Does this mean that the file name needs to be _main_.py?
I'm about 20 minutes ahead of you in learning Python, Pat, so I don't know about the module named _main_ stuff or how to make an egg executable. I suspect it's basically another layer on top of making a particular module executable.
AFAIK, a module is just a source file that can contain multiple classes etc. You can make a module executable by telling it how to respond if called (implicitly) as "__main__". This is the equivalent of a main() method in Java. In the example below, my module file contains two classes Foo and Bar, a "main()" method (which is not necessary but is handy for those of us who expect such things), and some code to spot if the module is being executed directly. Python will execute any code in the module that is not inside a function/class, but you usually only want it to do this if you're calling it directly e.g. from the command line. When the Python interpreter gets to the "if __name__..." bit, it executes it, knows it's being called directly as "__main__", and is then re-directed to my main() method.
This runs and produces output just as you would expect:
My guess is that you make an egg executable in an analogous fashion but I don't know how. Maybe just try creating a module called __main__.py containing some code like this, packaging it in an egg and then executing it?
No more Blub for me, thank you, Vicar.
F is for finger. Can you stick your finger in your nose? Doesn't that feel nice? Now try this tiny ad: