Originally Posted by rantanplan
if sys.argv[1:] == "":
print "Please enter adress."
Yes, that's how you'd test for an empty string, but this assumes that what was entered on the command line was quoted to begin with:
[dmcook@localhost ~]$ /tmp/test.py -f "" -g ""
['/tmp/test.py', '-f', '', '-g', '']
Not too likely. If they just leave off the arguments, you'll see:
['/tmp/test.py', '-f', '-g']
So checking for an empty string is not too helpful.
Instead I suggest the optparse module, which I think has been standard since 2.3. It makes adding command-line options to your programs very easy.