sys module - argv, but no argc ??
Peter Hansen
peter at engcorp.com
Sat Aug 3 08:57:43 EDT 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
http://optik.sourceforge.net, and to avoid reinventing the wheel.
-Peter
More information about the Python-list
mailing list