Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #67086 > unrolled thread
| Started by | Ganesh Pal <ganesh1pal@gmail.com> |
|---|---|
| First post | 2014-02-26 15:00 +0530 |
| Last post | 2014-02-26 02:55 -0800 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Python : parsing the command line options using optparse Ganesh Pal <ganesh1pal@gmail.com> - 2014-02-26 15:00 +0530
Re: Python : parsing the command line options using optparse sffjunkie@gmail.com - 2014-02-26 02:55 -0800
| From | Ganesh Pal <ganesh1pal@gmail.com> |
|---|---|
| Date | 2014-02-26 15:00 +0530 |
| Subject | Re: Python : parsing the command line options using optparse |
| Message-ID | <mailman.7386.1393407329.18130.python-list@python.org> |
[Multipart message — attachments visible in raw view] — view raw
On Tue, Feb 25, 2014 at 9:55 PM, Peter Otten <__peter__@web.de> wrote: >As you are just starting I recommend that you use argparse instead of optparse. I would love to use argparse but the script that I plan to write has to run on host machines that Python 2.6 I have freebsd clients with python 2.6 dont want to install python new version on all the host machine which will be eventually upgraded to 2.7 . I wanted know if I could use argparse with python 2.6 and is it possible to add something like #pkg_add -r install python-argparse and install python argparse module before I use it. > >If you are asking why short options don't work in conjunction with = -- I > >don't know, it is probably a design choice of the optparse author. > >argparse accepts short options with like -f=1234 > I wanted to know why my sample program does not work with short hand option (-p) and works with long hand option . Here is what is happening ( only short hand with -) # python-5.py -p=/ifs/1.txt -q=XOR -f=1234 -n=1 -l Usage: python-5.py [options] python-5.py: error: option -q: invalid choice: '=XOR' (choose from 'XOR', 'ADD', 'SET', 'MODIFY', 'RENAME', 'DELETE', 'KILL') Result :says invalid choice: '=XOR' Long hand Works ( -- , or double hypen ) fine. C:\Users\bahadg\Desktop>python python-5.py --path=/ifs/1.txt --operation=XOR -- offset=1234 --node=1 --log --fixcrc /ifs/1.txt
[toc] | [next] | [standalone]
| From | sffjunkie@gmail.com |
|---|---|
| Date | 2014-02-26 02:55 -0800 |
| Message-ID | <a098ce5f-467a-40cd-8085-bb9275168461@googlegroups.com> |
| In reply to | #67086 |
On Wednesday, 26 February 2014 09:30:21 UTC, Ganesh Pal wrote: > Here is what is happening ( only short hand with -) > > # python-5.py -p=/ifs/1.txt -q=XOR -f=1234 -n=1 -l > > Usage: python-5.py [options] > python-5.py: error: option -q: invalid choice: '=XOR' (choose from 'XOR', 'ADD', > > 'SET', 'MODIFY', 'RENAME', 'DELETE', 'KILL') Short hand options don't use '=' signs. Try python-5.py -p /ifs/1.txt -q XOR -f 1234 -n 1 -l --Simon
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web