Hi all,
I tried with the example Peter gave me, and it works. But only when the
options are boolean. At least, that is my conclusion with experimenting.
I'll elaborate:
The code to create 'mutually exclusive options':
option_names = [ l, o , s ]
toggled_options = [name for name in
Andy Kannberg wrote:
I tried with the example Peter gave me, and it works. But only when the
options are boolean. At least, that is my conclusion with experimenting.
I'll elaborate:
The code to create 'mutually exclusive options':
option_names = [ l, o , s ]
toggled_options = [name
Hi python-guru's,
I am new to Python, coming from a long history of Unix/linux shell
programming.
I am creating a Python script (In Python 2.6) which should be able to read
command line options and arguments.
So far, I figured out how to do that with optparse. I can add options (and
arguments )
Andy Kannberg wrote:
Hi python-guru's,
I am new to Python, coming from a long history of Unix/linux shell
programming.
I am creating a Python script (In Python 2.6) which should be able to
read command line options and arguments.
So far, I figured out how to do that with optparse. I can
I'm working on a python script that takes several command line flags,
currently parsed by hand. I'd like to change the script to parse them
with OptionParser from the optparse module. However, currently the
script invokes a subprocess, and any flags the script doesn't
understand it assumes are
On 2009-05-20 16:50, Joseph Garvin wrote:
I'm working on a python script that takes several command line flags,
currently parsed by hand. I'd like to change the script to parse them
with OptionParser from the optparse module. However, currently the
script invokes a subprocess, and any flags the
* Pat (Tue, 27 Jan 2009 14:04:28 -0500)
I had no idea people were going to get so upset that I used a
Windows example and go off on a tear.
Nobody is upset, and nobody has gone off on a tear. The point
about the Windows example is that the docs say in a
close-to-screamingly- obvious
* Pat (Mon, 26 Jan 2009 20:02:59 -0500)
Up until today, I never needed to pass any arguments to a Python
program.
[...]
getopt resolved my immediate need, but I would like to know how one
could use optparse to extract out the options from something like dir
/s /b.
If you actually read the
If you mean with / as the option designator instead of -: there
doesn't appear to be a documented way of doing it. You would have to
do some social engineering on the users to get them used to doing dir
-s -b. In any case I thought the number of Windows users who know how
to fire up a Command
Thorsten Kampe wrote:
* Pat (Mon, 26 Jan 2009 20:02:59 -0500)
Up until today, I never needed to pass any arguments to a Python
program.
[...]
getopt resolved my immediate need, but I would like to know how one
could use optparse to extract out the options from something like dir
/s /b.
If
On Jan 28, 12:06 am, Pat p...@junk.net wrote:
Thorsten Kampe wrote:
* Pat (Mon, 26 Jan 2009 20:02:59 -0500)
Up until today, I never needed to pass any arguments to a Python
program.
[...]
getopt resolved my immediate need, but I would like to know how one
could use optparse to extract
* John Machin (Tue, 27 Jan 2009 05:31:42 -0800 (PST))
Nobody is upset, and nobody has gone off on a tear. The point about
the Windows example is that the docs say in a close-to-screamingly-
obvious manner that /options are not supported, no matter what
religion uses them. It was not, and still
I had no idea people were going to get so upset that I used a Windows
example and go off on a tear.
Nobody is upset, and nobody has gone off on a tear. The point about
the Windows example is that the docs say in a close-to-screamingly-
obvious manner that /options are not supported, no
Pat wrote:
The question was it possible to add a simple flag like 'd-' to optparse
with no other parameters?
Do you mean d- or -d? If the latter, what's wrong with Robert Kern's
answer?
Peter
--
http://mail.python.org/mailman/listinfo/python-list
Peter Otten wrote:
Pat wrote:
The question was it possible to add a simple flag like 'd-' to optparse
with no other parameters?
Do you mean d- or -d? If the latter, what's wrong with Robert Kern's
answer?
Peter
I mean -d since that's what Unix commands expect for flags.
My sole
Peter Otten wrote:
Pat wrote:
The question was it possible to add a simple flag like 'd-' to optparse
with no other parameters?
Do you mean d- or -d? If the latter, what's wrong with Robert Kern's
answer?
I guess it got crowded out by the prima donnas anxious to help Pat
phrase his/her
Up until today, I never needed to pass any arguments to a Python program.
I did all the requisite reading and found that I should use optparse
instead of getopt. I read the documentation and since the words
simple and easy often appeared in the examples and documentation, I
just knew that
On Tue, Jan 27, 2009 at 11:02 AM, Pat p...@junk.net wrote:
(...)
What does it take to pass single parameter to a program?
http://docs.python.org/library/optparse.html stated that programs always
have options. Is that so? What about dir /s?
Sample code:
On 2009-01-26 19:02, Pat wrote:
Up until today, I never needed to pass any arguments to a Python program.
I did all the requisite reading and found that I should use optparse
instead of getopt. I read the documentation and since the words simple
and easy often appeared in the examples and
I did all the requisite reading and found that I should use optparse
instead of getopt. I read the documentation and since the words
simple and easy often appeared in the examples and documentation, I
just knew that it would be a snap to implement.
I don't know where you got that. 'getopt'
On Jan 27, 12:02 pm, Pat p...@junk.net wrote:
Up until today, I never needed to pass any arguments to a Python program.
I did all the requisite reading and found that I should use optparse
instead of getopt. I read the documentation and since the words
simple and easy often appeared in the
I have a short program using optparse.OptionParser that prints out help
message with -h flag:
% myprog.py -h
usage: myprog.py [options] input_file
options:
-h, --help show this help message and exit
-v, --verboseprint program's version number and exit
-o FILE
T wrote:
I have a short program using optparse.OptionParser that prints out help
message with -h flag:
% myprog.py -h
usage: myprog.py [options] input_file
options:
-h, --help show this help message and exit
-v, --verboseprint program's version number and exit
fuzzylollipop wrote:
you can make the usage line anything you want.
...
usage = 'This is a line before the usage line\nusage %prog [options]
input_file'
parser = OptionsParser(usage=usage)
parser.print_help()
...
No, that affects the string printed only *after* the usage = string.
No, that affects the string printed only *after* the usage = string.
What I would like to do is insert some string *before* the usage =
string, which is right after the command I type at the command prompt.
So I would like to make it look like this:
The example was fine (except for a typo)
T wrote:
fuzzylollipop wrote:
you can make the usage line anything you want.
...
usage = 'This is a line before the usage line\nusage %prog [options]
input_file'
parser = OptionsParser(usage=usage)
parser.print_help()
...
No, that affects the string printed only *after* the
[EMAIL PROTECTED] wrote:
No, that affects the string printed only *after* the usage = string.
What I would like to do is insert some string *before* the usage =
string, which is right after the command I type at the command prompt.
So I would like to make it look like this:
The
T wrote:
fuzzylollipop wrote:
you can make the usage line anything you want.
...
usage = 'This is a line before the usage line\nusage %prog [options]
input_file'
parser = OptionsParser(usage=usage)
parser.print_help()
...
No, that affects the string printed only *after* the usage =
Nope. That only *nearly* does what T wants. The usage message will
still be printed immediately *after* the 'usage: ' string.
parser = OptionParser(usage=usage)
parser.print_help()
usage: THIS IS NEWLY INSERTED STRING
usage: lopts.py [options] input_file
T [EMAIL PROTECTED] writes:
[...]
What I would like to do is insert some string *before* the usage =
string, which is right after the command I type at the command prompt.
So I would like to make it look like this:
% myprog.py -h
THIS IS NEWLY INSERTED STRING
30 matches
Mail list logo