Re: option argument length

2005-12-07 Thread Peter Otten
Ritesh Raj Sarraf wrote: > ./sarraf.py --fetch-update /bar > > If the user gives the /bar argument, the program should save the > downloaded files to /bar. But I'm assuming that the user could be dumb or > too lazy, in which case --fetch-udpate should use the parser.set_defaults > value i.e. /foo

Re: option argument length

2005-12-07 Thread Ritesh Raj Sarraf
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi Peter, Peter Otten on Wednesday December 7 2005 21:25 wrote: > This can be simplified to > > parser.add_option("-d", "--download-dir", default="foo", > help="Root directory path to save the downloaded files") > > which seems to be the reaso

Re: option argument length

2005-12-07 Thread Peter Otten
Ritesh Raj Sarraf wrote: > parser.add_option("-d","--download-dir", dest="download_dir", > help="Root directory path to save the downloaded files", > action="store", type="string") > parser.set_defaults(download_dir="foo") This can be simplified to parser.add_

Re: option argument length

2005-12-07 Thread Ritesh Raj Sarraf
On Tue, 6 Dec 2005, Peter Otten wrote: > Ritesh Raj Sarraf wrote: > >> I'm using this for "option arguments" which are mutually inclusive. >> But I want the user to pass atleast one "option argument" for the program >> to function properly. >> >> For example, I have an option "--fetch-update" whic

Re: option argument length

2005-12-06 Thread Peter Otten
Ritesh Raj Sarraf wrote: > I'm using this for "option arguments" which are mutually inclusive. > But I want the user to pass atleast one "option argument" for the program > to function properly. > > For example, I have an option "--fetch-update" which requires a file "foo" > to check what it has

Re: option argument length

2005-12-05 Thread Ritesh Raj Sarraf
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Peter Otten on Monday December 5 2005 03:34 wrote: > options, args = parser.parse_args(values=MyValues()) > > but you should do your users a favour and give them meaningful error > messages. I can't conceive how you could achieve this by checking the

Re: option argument length

2005-12-05 Thread Ritesh Raj Sarraf
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Marc 'BlackJack' Rintsch on Monday December 5 2005 03:24 wrote: > In <[EMAIL PROTECTED]>, 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

Re: option argument length

2005-12-04 Thread Nicolas Couture
I don't think that's actually what you want to do. Yes arguments are not to be used directly as option arguments (otherwise why have option arguments anyways ;-) but each option argument is usually evaluated under the evaluation of the actual option and optparse will error on invalid use of the opt

Re: option argument length

2005-12-04 Thread Peter Otten
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: >

Re: option argument length

2005-12-04 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, 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) !=

option argument length

2005-12-04 Thread Ritesh Raj Sarraf
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi, I'm using optparse module to parse all options and arguments. 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: (op