len(sys.argv) in (3,4)

Daniel Dittmar daniel.dittmar at sap.corp
Thu Aug 11 12:04:13 EDT 2005


Daniel Schüle wrote:
> if __name__ == "__main__":
>     if len(sys.argv) not in (3,4):
>         print "usage: prog arg1 argv2 [-x]"
>     # etc ...
> 
> while develeoping I had my interpeter running and reloaded module
> now since I am ready, I wanted to run it from cmd windows shell
> but it always prints "usage ..."
> I added print len(sys.arg) and it prints 1 though I am provinding more
> than 1 value

Add

import sys
print sys.argv

at the top of the script before any other import.
Maybe one of the modules you're importing messes with sys.argv

Daniel



More information about the Python-list mailing list