Beginner problem.
Eric Brunel
eric.brunel at pragmadev.com
Mon Feb 11 06:17:53 EST 2002
Hi,
"DelPiccolo Ivano" <ivano.delpiccolo at degroof.be> a écrit dans le message
news: 3c67a6a3$0$12223$4d4efb8e at news.be.uu.net...
> Here's my script, where is the error ?
>
> import sys
>
> if sys.argv[??????] == "" :
> print "Usage : sys.argv[0] logname string_to_search"
> else :
You're not in a shell script: all arguments are not implicitely set to "".
To test how much arguments are passed, just test the length of the sys.argv
list. E.g.:
import sys
if len(sys.argv) != 3:
print "Usage: %s logname string_to_search" % sys.argv[0]
It's as simple as that... HTH
- eric -
More information about the Python-list
mailing list