> Also, I hear that optparse is much better than getopt.
this is a true pleasure to work with optparse. It was included in python2.3 and
was primarly called python-optik
Ced.
--
Cedric BRINER
___
Tutor maillist - Tutor@python.org
http://mail.py
>
> If I have arguments, the "different stuff" happens beautifully, thank
> you very much. If I don't have arguments I get this:
>
> if sys.argv[1]:
> IndexError: list index out of range]
>
> So I'm doing something wrong. I looked at getopt, but that seemed to be
> doing what I was already doing,
On May 14, 2005, at 01:30, William O'Higgins wrote:
> if sys.argv[1]:
> do stuff
> else:
> do different stuff
>
> If I have arguments, the "different stuff" happens beautifully, thank
> you very much. If I don't have arguments I get this:
>
> if sys.argv[1]:
> IndexError: list index out
I am writing a tiny commandline utility (re-writing it from Perl) and I
want the behaviour to change based on the presence of arguments. The
conditional in Perl looks like this:
if (defined $ARGV[0]) {
do stuff
} else {
do different stuff
In Python I've nearly been successful, but someth