sys module - argv, but no argc ??

Peter Hansen peter at
Sat Aug 3 14:57:43 CEST 2002

TuxTrax wrote:
> I am sure that this isn't the most elegant way of parsing the command
> line, but it works well. And no index out of bounds errors, thus no
> need for argc.
> # Check to see if command line has any perimeters. -s is newserver,
> # -g is group. Range indexes manually, and allows the disregarding of
> # argv[0] the way a slice would.
> import string
> import sys

[snip code]

You're probably right that it's not the most elegant way.  The
most elegant way might be to use one of the existing modules,
perhaps getopt from the standard library, or Optik at, and to avoid reinventing the wheel.


More information about the Python-list mailing list