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 which requires a file
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_option(-d,
-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 reason why I've
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
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 to fetch. If
-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 correct
-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
-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:
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) != 1 or
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Â
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
11 matches
Mail list logo