Typical convention here is ([thread on the topic](http://www.artima.com/forums/flat.jsp?forum=106&thread=4829)):

```
def main():
    # parse command line args 
    # call functions in rest of script
  
if __name__ == "__main__":
    sys.exit(main())
```

This will let the script be imported as a module and be run as a script