lazaridis_com wrote:

> Are ther alternative constructs/mechanism available, which could be
> used to add this functionality possiby directly to a code-module?

How about something along these lines:

------------------ auto.py ---------
import sys, atexit

def main_body(f):
    if f.func_globals['__name__']=='__main__':
        atexit.register(f, sys.argv)
    return f

@main_body
def auto(args):
    print "auto run", args
------------------------------------

If you run auto.py as a script then the decorated function executes. If you 
import it then the decorated function doesn't execute. In your own script 
you just need an import statement and to put the decorator on your main 
function.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to