Two things: (1) your #!/use/bin/python
needs to be the first thing in your file, and (2) you need to add a call to main
. As it is, you're defining it, but not actually calling it.
In Python, you would not normally pass command-line arguments to main
, since they are available in sys.argv
. So you would define main
as not taking any arguments, then call it at the bottom of your file with:
if __name__ == "__main__":
sys.exit(main())
The test for __name__
prevents main
from being called if the file is being imported, as opposed to being executed, which is the standard way to handle it.
If you want to explicitly pass the command line arguments to main
, you can call it as:
if __name__ == "__main__":
sys.exit(main(sys.argv))
which is what you would need to do with the definition you currently have.