option argument length

Ritesh Raj Sarraf rrs at researchut.com
Mon Dec 5 13:28:14 EST 2005


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Marc 'BlackJack' Rintsch on Monday December 5 2005 03:24 wrote:

> In <mailman.1573.1133729565.18701.python-list at python.org>, Ritesh Raj
> Sarraf wrote:
> 
>> My program uses mostly "option arguments" hence my len(args) value is
>> always zero. I need to check if the user has passed the correct number of
>> "option arguments". Something like:
>> 
>> (options,args) = parser.parse_args()
>> 
>> len(options) != 1 or len(options) > 2:
>>         print "Incorrect number of arguments passed."
>> 
>> How do I accomplish it ?
> 
> Just insert an ``if`` in front of the condition and end the program with
> ``sys.exit()`` after the message.
> 
> Ciao,
> Marc 'BlackJack' Rintsch

This won't help because "options" is an instance.

Regards,

rrs
- -- 
Ritesh Raj Sarraf
RESEARCHUT -- http://www.researchut.com
"Stealing logics from one person is plagiarism, stealing from many is
research."
"Necessity is the mother of invention."

Note: Please CC me. I'm not subscribed to the list
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iD8DBQFDlIbH4Rhi6gTxMLwRAlgSAJ0Y3TT9eCBgrck5N2Y9YjOTZMxUgwCcDeO5
qqgzY6rz2E4YKvurnlHL0nQ=
=hlZO
-----END PGP SIGNATURE-----




More information about the Python-list mailing list