python empty argument

arguments, parameter-passing, python

Solution

if len(sys.argv) == 1:
    # Print usage...

The first element of sys.argv is always either the name of the script itself, or an empty string. If sys.argv has only one element, then there must have been no arguments.

http://docs.python.org/library/sys.html#sys.argv

Problem

how do I print help info if no arguments are passed to python script? ``` #!/usr/bin/env python import sys for arg in sys.argv: if arg == "do": do this if arg == "" print "usage is bla bla bla" ``` what I'm missing is `if arg == ""` line that I don't know how to express :(

Original source