* Jay Loden <[EMAIL PROTECTED]> [2005-07-11 22:30]:
> I have an app that takes a command line argument of -l or --list.  It uses 
> the 
> getopt module to parse the arguments, and I just noticed that for some 
> reason, getopt is matching "--lis" or "--li" etc to "--list". (Code pasted in 
> below)
> 
> Is this normal behavior, and if so, is there any way to avoid this? I just 
> want it to match "--list" to "--list", not "--l" and "--li" and "--lis" etc. 

This is normal.

From getopt http://docs.python.org/lib/module-getopt.html

 Long options on the command line can be recognized so long as they
 provide a prefix of the option name that matches exactly one of the
 accepted options. For example, if long_options is ['foo', 'frob'], the
 option --fo will match as --foo, but --f will not match uniquely, so
 GetoptError will be raised.

-- 
David Rock
[EMAIL PROTECTED]

Attachment: pgpzJhOCWT42I.pgp
Description: PGP signature

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to