Re: Optparse to parsing Suggestions !!

2014-05-31 Thread Ian Kelly
On May 30, 2014 8:26 AM, "Ganesh Pal" wrote: > > > Hello Python world , > > > I wanted suggestion on how to modify the below code to help me accomodate the below two cases Your question was answered already, but I'd like to point out that optparse is deprec

Re: Optparse to parsing Suggestions !!

2014-05-31 Thread Peter Otten
Am Sa Mai 31 2014, 13:08:12 schrieb Ganesh Pal: >> I think you have to do it manually: >> >> options, args = parser.parse_args() >> >> if options.object == "super_block" and options.path is not None: >> parser.error("Paths not allowed for 'super_block' object") >> >> elif options.object ==

Re: Optparse to parsing Suggestions !!

2014-05-30 Thread Peter Otten
hoice) + ') default: %default]',) > > parser.add_option("-p", > "-- path",action="store",metavar="/mnt/",dest="path",type="string",help="The > file or directory path in /mnt/",) > >

Re: Optparse to parsing Suggestions !!

2014-05-30 Thread Ganesh Pal
join(object_choice) + ') default: %default]',) > > parser.add_option("-p", > "--path",action="store",metavar="/mnt/",dest="path",type="string",help="The > file or directory path in /mnt/",) >

Optparse to parsing Suggestions !!

2014-05-30 Thread Ganesh Pal
pe='choice', choices=object_choice, help='The object type to be corrupted [ choose from (' + ','.join(object_choice) + ') default: %default]',) parser.add_option("-p", "--path",action="store",metavar="/m

Re: Python : parsing the command line options using optparse

2014-03-01 Thread Ganesh Pal
On Sat, Mar 1, 2014 at 5:17 PM, Steven D'Aprano < steve+comp.lang.pyt...@pearwood.info> wrote: > > You should start new threads for new questions. The subject line here has > nothing to do with the questions you ask. > > Sure Steven and thanks for replying and your suggestion for Question 2 (

Re: Python : parsing the command line options using optparse

2014-03-01 Thread Ganesh Pal
> > handler = object_type_dictionary[options.object_type] # look up the > function > handler() # call it > > The last two lines could also be merged into one > > object_type_dictionary[options.object_type]() > > but the first version may be clearer. > > Thanks for your valuable inputs all worked

Re: Python : parsing the command line options using optparse

2014-03-01 Thread Steven D'Aprano
On Sat, 01 Mar 2014 16:43:11 +0530, Ganesh Pal wrote: > Iam done with the command line parsing but got stuck while trying to > implement switch kind of behavior with dictionaries. So posting 2 more > questions You should start new threads for new questions. The subject line here has nothing to

Re: Python : parsing the command line options using optparse

2014-03-01 Thread Peter Otten
Ganesh Pal wrote: > Iam using the options.name directly for manipulations is this fine or do > I need to assign it to variable and then use it > if options.object_type == 'LIN': >corrupt_inode() This is fine. You would only consider storing the value if you are going to use it very of

Re: Python : parsing the command line options using optparse

2014-03-01 Thread Ganesh Pal
> > > > Thanks Peter and Simon for the hints it worked : ) without ' =' > > # Python corrupt.py -o INODE -p /ifs/1.txt -q SET -f 1 > > Current Default Choice : > > Choice: INODE > Choice: SET > Choice: 1 > > > > Iam done with the command line parsing but got stuck while trying to implement sw

Re: Python : parsing the command line options using optparse

2014-02-27 Thread Ganesh Pal
> > They must be running an older version of FreeBSD since the default version > of python is 2.7. > > There is a FreeBSD package for argparse, the command would be something > like >pkg_add -r install py26-argparse > > > Rod > > Yes Iam running a older version of FreeBSD ( Iam actually run

Re: Python : parsing the command line options using optparse

2014-02-26 Thread rodperson
On 2014-02-26 04:30, Ganesh Pal wrote: On Tue, Feb 25, 2014 at 9:55 PM, Peter Otten <__pete...@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 machine

Re: Python : parsing the command line options using optparse

2014-02-26 Thread Ganesh Pal
On Wed, Feb 26, 2014 at 4:57 PM, Peter Otten <__pete...@web.de> wrote: > > If you stick with optparse just pass the options without '=' > > -qXOR > > and > > -q XOR > > should both work. > > Thanks Peter and Simon for the hints it worked : )

Re: Python : parsing the command line options using optparse

2014-02-26 Thread Peter Otten
Ganesh Pal wrote: > On Tue, Feb 25, 2014 at 9:55 PM, Peter Otten <__pete...@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

Re: Python : parsing the command line options using optparse

2014-02-26 Thread sffjunkie
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', > >

Re: Python : parsing the command line options using optparse

2014-02-26 Thread Ganesh Pal
On Tue, Feb 25, 2014 at 9:55 PM, Peter Otten <__pete...@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 clie

Re: Python : parsing the command line options using optparse

2014-02-25 Thread Mark Lawrence
On 25/02/2014 15:31, Ganesh Pal wrote: Hi Folks , Iam newbie to Python, Iam trying to use optparse module and write a script that will parse the command line options ..I had to use opt parse instead of argparse because by host Operating system is still using python 2.6 Do you have the

Re: Python : parsing the command line options using optparse

2014-02-25 Thread Peter Otten
Ganesh Pal wrote: > Iam newbie to Python, Iam trying to use optparse module and write a script > that will parse the command line options ..I had to use opt parse instead > of argparse because by host Operating system is still using python 2.6 As you are just starting I recommend tha

Python : parsing the command line options using optparse

2014-02-25 Thread Ganesh Pal
Hi Folks , Iam newbie to Python, Iam trying to use optparse module and write a script that will parse the command line options ..I had to use opt parse instead of argparse because by host Operating system is still using python 2.6 Below is the simple program ( Feel free to correct the error

Re: optparse question (python 2.6)

2013-09-02 Thread Peter Otten
ot;/usr/lib64/python2.6/optparse.py", line 577, in __init__ > checker(self) > File "/usr/lib64/python2.6/optparse.py", line 706, in _check_nargs > self) > optparse.OptionError: option -s: 'nargs' must not be supplied for action > 'store_t

Re: optparse question (python 2.6)

2013-09-02 Thread Andy Kannberg
Andy 2013/8/27 Andy Kannberg > Hello Peter, > > Thanks for the example. For now I am restricted to Python 2.6, so no > argparse for me at the moment. > > cheers, > Andy > > > 2013/8/26 Peter Otten <__pete...@web.de> > >> Andy Kannberg wrote: >> >&

Re: optparse question (python 2.6)

2013-08-26 Thread Peter Otten
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 ho

optparse question (python 2.6)

2013-08-26 Thread Andy Kannberg
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 argu

Re: Introspecting optparse/argparse objects

2012-01-11 Thread Evan Driscoll
n of 'concrete use case', but anyway... It's actually closer to the truth than it might seem. I want to feed a bash-completion-style thing, using the same data structure to both figure out the possible completions and also do the actual parsing. "Do the actual parsing" = optpars

Re: Introspecting optparse/argparse objects

2012-01-11 Thread alex23
> if I asked for it I might get it in a future version? Not in optparse, as it's no longer being developed. For argparse, you might want a better use case: adding functionality to support a hypothetical "lack" of functionality (which is _actually_ provides) seems like a pedantic exercise to me. -- http://mail.python.org/mailman/listinfo/python-list

Introspecting optparse/argparse objects

2012-01-10 Thread Evan Driscoll
his. Even if I were to do something like options = [ make_option(...), make_option(...) ] (using optparse) and could thus get a handle on the Option objects, there doesn't seem to be a public API for retrieving stuff like the actual options (though available via opt._short_opts and opt._lo

Re: argparse missing optparse capabilities?

2012-01-05 Thread ru...@yahoo.com
On 01/05/2012 11:46 AM, Ian Kelly wrote: > On Thu, Jan 5, 2012 at 11:14 AM, Ian Kelly wrote: >> On Thu, Jan 5, 2012 at 1:05 AM, ru...@yahoo.com wrote: >>> I have optparse code that parses a command line containing >>> intermixed positional and optional arguments, where

Re: argparse missing optparse capabilities?

2012-01-05 Thread Ian Kelly
On Thu, Jan 5, 2012 at 11:14 AM, Ian Kelly wrote: > On Thu, Jan 5, 2012 at 1:05 AM, ru...@yahoo.com wrote: >> I have optparse code that parses a command line containing >> intermixed positional and optional arguments, where the optional >> arguments set the context for the

Re: argparse missing optparse capabilities?

2012-01-05 Thread Ian Kelly
On Thu, Jan 5, 2012 at 1:05 AM, ru...@yahoo.com wrote: > I have optparse code that parses a command line containing > intermixed positional and optional arguments, where the optional > arguments set the context for the following positional arguments. > For example, > >  mypr

Re: argparse missing optparse capabilities?

2012-01-05 Thread ru...@yahoo.com
On 01/05/2012 02:19 AM, Ulrich Eckhardt wrote: > Am 05.01.2012 09:05, schrieb ru...@yahoo.com: >> I have optparse code that parses a command line containing >> intermixed positional and optional arguments, where the optional >> arguments set the context for the following

Re: argparse missing optparse capabilities?

2012-01-05 Thread Ulrich Eckhardt
Am 05.01.2012 09:05, schrieb ru...@yahoo.com: I have optparse code that parses a command line containing intermixed positional and optional arguments, where the optional arguments set the context for the following positional arguments. For example, myprogram.py arg1 -c33 arg2 arg3 -c44 arg4

Re: argparse missing optparse capabilities?

2012-01-05 Thread ru...@yahoo.com
On Jan 5, 1:05 am, "ru...@yahoo.com" wrote: >   class AppendWithPos (argparse.Action): >     def __call__ (self, parser, namespace, values, > option_string=None): >         if getattr (namespace, self.dest, None) is None: >             setattr (namespace, self.dest, []) >         getattr (namespac

argparse missing optparse capabilities?

2012-01-05 Thread ru...@yahoo.com
I have optparse code that parses a command line containing intermixed positional and optional arguments, where the optional arguments set the context for the following positional arguments. For example, myprogram.py arg1 -c33 arg2 arg3 -c44 arg4 'arg1' is processed in a default conte

Re: How to generate error when argument are not supplied and there is no explicit defults (in optparse)?

2011-10-15 Thread ru...@yahoo.com
rser fail if an argument's value (which has no default > explicitly specified) is not specified. I may miss some thing in the > manual. Could any expert let me know if there is a way to do so? > Thanks! > > #!/usr/bin/env python > > from optparse import OptionParser > &g

Re: How to generate error when argument are not supplied and there is no explicit defults (in optparse)?

2011-10-14 Thread Miki Tebeka
Don't specify it as an option, but as an argument. If you're on a new version of python, you should probably use argparse. -- http://mail.python.org/mailman/listinfo/python-list

How to generate error when argument are not supplied and there is no explicit defults (in optparse)?

2011-10-14 Thread Peng Yu
ly specified) is not specified. I may miss some thing in the manual. Could any expert let me know if there is a way to do so? Thanks! #!/usr/bin/env python from optparse import OptionParser usage = 'usage: %prog [options] arg1 arg2' parser = OptionParser(usage=usage) parser.set_defa

Re: Optparse buggy?

2011-09-01 Thread Carl Banks
On Thursday, September 1, 2011 7:16:13 PM UTC-7, Roy Smith wrote: > In article , > Terry Reedy wrote: > > > Do note "The optparse module is deprecated and will not be developed > > further; development will continue with the argparse module." > > One of

Re: Optparse buggy?

2011-09-01 Thread Ben Finney
Fulvio writes: > Terry Reedy wrote: > > > Do note "The optparse module is deprecated and will not be developed > > further; development will continue with the argparse module." > > Then,do you propose me to opt to argparse? Without argument, yes; though for now

Re: Optparse buggy?

2011-09-01 Thread Fulvio
Terry Reedy wrote: > Do note "The optparse module is deprecated and will not be developed > further; development will continue with the argparse module." Then,do you propose me to opt to argparse? -- Archlinux on $(uname -a) :P F -- http://mail.python.org/mailman/listinfo/python-list

Re: Optparse buggy?

2011-09-01 Thread Roy Smith
In article , Terry Reedy wrote: > Do note "The optparse module is deprecated and will not be developed > further; development will continue with the argparse module." One of the unfortunate things about optparse and argparse is the names. I can never remember which is the n

Re: Optparse buggy?

2011-09-01 Thread Terry Reedy
On 9/1/2011 5:12 PM, Fulvio wrote: I'm on python3.2, trying some experiment with OptionParser but no success Do note "The optparse module is deprecated and will not be developed further; development will continue with the argparse module." -- Terry Jan Reedy -- http://

Re: Optparse buggy?

2011-09-01 Thread Jason Swails
On Thu, Sep 1, 2011 at 5:12 PM, Fulvio wrote: > Hello, > > I'm on python3.2, trying some experiment with OptionParser but no success > > >>> from optparse import OptionParser as parser > >>> parser.add_option('-n','--new',

Re: Optparse buggy?

2011-09-01 Thread Ian Kelly
On Thu, Sep 1, 2011 at 3:12 PM, Fulvio wrote: > Hello, > > I'm on python3.2, trying some experiment with OptionParser but no success > >>>> from optparse import OptionParser as parser >>>> parser.add_option('-n','--new', dest='

Optparse buggy?

2011-09-01 Thread Fulvio
Hello, I'm on python3.2, trying some experiment with OptionParser but no success >>> from optparse import OptionParser as parser >>> parser.add_option('-n','--new', dest='new') >>>

Re: Customize help output from optparse (or argparse)

2011-05-21 Thread Thorsten Kampe
* Thomas 'PointedEars' Lahn (Thu, 12 May 2011 22:22:20 +0200) > Thorsten Kampe wrote: > > I'm using optparse for a little Python script. > > > > 1. The output from "--help" is: > > """ > > Usage: script.py > > &

Re: Customize help output from optparse (or argparse)

2011-05-12 Thread Karim
On 05/12/2011 10:22 PM, Thomas 'PointedEars' Lahn wrote: Thorsten Kampe wrote: I'm using optparse for a little Python script. 1. The output from "--help" is: """ Usage: script.py script.py does something Options: -h, --help show this help mess

Re: Customize help output from optparse (or argparse)

2011-05-12 Thread Thomas 'PointedEars' Lahn
Thorsten Kampe wrote: > I'm using optparse for a little Python script. > > 1. The output from "--help" is: > """ > Usage: script.py > > script.py does something > > Options: > -h, --help show this help message and exit > &

Customize help output from optparse (or argparse)

2011-05-12 Thread Thorsten Kampe
Hi, I'm using optparse for a little Python script. 1. The output from "--help" is: """ Usage: script.py script.py does something Options: -h, --help show this help message and exit """ I would prefer to have the description before the usage

Re: optparse eats $

2011-04-19 Thread Michael Kent
Try this on your *nix command line: echo ">$100" On a *nix command line, the '$1' part of ">$100" will be seen as 'give me the value of the shell variable "1"', and since it has no value, will result in an empty string. So it's not o

Re: optparse eats $

2011-04-19 Thread Peter Otten
tazz_ben wrote: > So, I'm using optparse as follows: > > Command line: > python expense.py ">$100" -f ~/desktop/test.txt > ['>00'] > > > In Main: > > desc = '' > p = optparse.OptionParser(description=desc) > &g

Re: optparse eats $

2011-04-19 Thread John Gordon
In tazz_ben writes: > So, any ideas? Why is including a $ eating both the dollar signa and the 1? Unix command lines tend to assume any $ inside double-quotes is a shell variable name. Try enclosing in single-quotes instead. -- John Gordon A is for Amy, who fell down the

optparse eats $

2011-04-19 Thread tazz_ben
So, I'm using optparse as follows: Command line: python expense.py ">$100" -f ~/desktop/test.txt ['>00'] In Main: desc = '' p = optparse.OptionParser(description=desc) utilities = optparse.OptionGroup(p, 'Utility Options') utilities.a

Re: How to use optparse without the command line?

2011-04-13 Thread Miki Tebeka
> But I find it dumb to encode and decode a dictionary... So I would > like to know how I if there is a good way of passing a dictionary to > optparse and benefiting from its option management (check, error > detection, etc). I don't think you can get away from encoding/de

Re: How to use optparse without the command line?

2011-04-13 Thread markolopa
On Apr 8, 11:58 pm, Karim wrote: > On 04/07/2011 10:37 AM, markolopa wrote: > > > Is there support/idioms/suggestions for usingoptparsewithout a > >commandline? > > > I have a code which used to be called through subprocess. The whole > > flow of the code is based on what 'options' object fromoptp

Re: How to use optparse without the command line?

2011-04-08 Thread Karim
On 04/07/2011 10:37 AM, markolopa wrote: Hello, Is there support/idioms/suggestions for using optparse without a command line? I have a code which used to be called through subprocess. The whole flow of the code is based on what 'options' object from optparse contains. Now I want to

How to use optparse without the command line?

2011-04-07 Thread markolopa
Hello, Is there support/idioms/suggestions for using optparse without a command line? I have a code which used to be called through subprocess. The whole flow of the code is based on what 'options' object from optparse contains. Now I want to call this code without subprocessing.

Re: optparse/argparse for cgi/wsgi?

2010-12-14 Thread Joost Molenaar
nse code is returned. > > HTH > > Joost > > > On 10 December 2010 17:36, samwyse wrote: > >> Has anyone ever built some sort of optparse/argparse module for cgi/ >> wsgi programs? I can see why a straight port wouldn't work, but a >> module that can organ

Re: optparse/argparse for cgi/wsgi?

2010-12-14 Thread Joost Molenaar
called, else a 'Method Not Allowed' response code is returned. HTH Joost On 10 December 2010 17:36, samwyse wrote: > Has anyone ever built some sort of optparse/argparse module for cgi/ > wsgi programs? I can see why a straight port wouldn't work, but a > module that

optparse/argparse for cgi/wsgi?

2010-12-10 Thread samwyse
Has anyone ever built some sort of optparse/argparse module for cgi/ wsgi programs? I can see why a straight port wouldn't work, but a module that can organize parameter handling for web pages seems like a good idea, especially if it provided a standard collection of both client- and server

Re: OptParse and Constant values

2010-08-12 Thread J
On Thu, Aug 12, 2010 at 12:41, Robert Kern wrote: > On 8/12/10 11:19 AM, J wrote: >> >> How do you use OptParse with constants? > http://docs.python.org/library/optparse#standard-option-actions > > 'store_const' means that the option is a flag without arguments

Re: OptParse and Constant values

2010-08-12 Thread Robert Kern
On 8/12/10 11:19 AM, J wrote: How do you use OptParse with constants? Example: usage = 'Usage: %prog [OPTIONS]' parser = OptionParser(usage) parser.add_option('-l','--level', action='store_const',

OptParse and Constant values

2010-08-12 Thread J
How do you use OptParse with constants? Example: usage = 'Usage: %prog [OPTIONS]' parser = OptionParser(usage) parser.add_option('-l','--level', action='store_const', default=LOG_INFO,

Re: optparse TypeError

2010-06-28 Thread Michele Simionato
On Jun 28, 11:47 pm, rantingrick wrote: > Give your *script* an > enema, and do *yourself* a favor by harnessing the simplistic elegance > of the "optphart" module instead! > > #-- Start Script --# > def optphart(args): >     d = {'args':[]} >     for arg in args: >         if arg.startswith('-'):

Re: optparse TypeError

2010-06-28 Thread Michele Simionato
On Jun 28, 9:56 pm, Ben Finney wrote: > Michele Simionato writes: > > optparse is so old-fashioned. Use plac! > > The OP should be made aware that: > > * plac is a third-party library with (TTBOMK) no prospect of inclusion >   in the standard library > > * optparse

Re: optparse TypeError

2010-06-28 Thread rantingrick
On Jun 28, 10:44 am, Michele Simionato wrote: > optparse is so old-fashioned. Use plac! Hog wash! Both are archaic and asinine. Both clog your scripts with wasted lines and your memory with complex interfaces far worse than colon clogging junk food can hold a candle to. Give your *script*

Re: optparse TypeError

2010-06-28 Thread Ben Finney
Michele Simionato writes: > optparse is so old-fashioned. Use plac! The OP should be made aware that: * plac is a third-party library with (TTBOMK) no prospect of inclusion in the standard library * optparse is in the standard library and has been for many versions * argparse is a th

Re: optparse TypeError

2010-06-28 Thread Michele Simionato
type="str", >                       help="T(op) or B(ottom)") > >     (options, args) = parser.parse_args() >     if len(args) != 1: >         parser.error("incorrect number of arguments") >     lines=options.lines >     tb=options.topbottom >

Re: optparse TypeError

2010-06-28 Thread Simon Brunning
On 28 June 2010 14:30, dirknbr wrote: > I get an int object is not callable TypeError when I execute this. But > I don't understand why. > (snip) >    lines=options.lines Here you are assigning the -l option to the name 'lines'. >    lines(args[0],topbottom=tb,maxi=lines) Here you are attemptin

optparse TypeError

2010-06-28 Thread dirknbr
I get an int object is not callable TypeError when I execute this. But I don't understand why. parser = optparse.OptionParser("usage: %lines [options] arg1") parser.add_option("-l", "--lines", dest="lines", default=10, type="int", help="number of

Re: optparse: best way

2010-06-09 Thread Jean-Michel Pichavant
is the most simple way to parser options. Can you please suggest any other best way / optimized way to parse these kind of options. Thank you in advance. Here's a solution: import optparse class Process: PREFIX = 'dispatch_' @staticmethod def undef()

Re: optparse: best way

2010-06-09 Thread hiral
On Jun 8, 4:30 pm, Hrvoje Niksic wrote: > Thomas Jollans writes: > > UNIX and GNU recommendations. I've never actually heard of optparser, > > but I'd expect it to have the usual limitations: > > Hiralprobably meant to write "optparse", which supports GNU

Re: optparse: best way

2010-06-09 Thread hiral
ser.add_option("-oppt', dest=ppt_file...) > > > The above way is the most simple way to parser options. > > Can you please suggest any other best way / optimized way to parse > > these kind of options. > > > Thank you in advance. > > Here's a s

Re: optparse: best way

2010-06-08 Thread Hrvoje Niksic
Thomas Jollans writes: > UNIX and GNU recommendations. I've never actually heard of optparser, > but I'd expect it to have the usual limitations: Hiral probably meant to write "optparse", which supports GNU-style options in a fairly standard and straightforward

Re: optparse: best way

2010-06-08 Thread Peter Otten
hiral wrote: > Hi, > > I am using optparser to do following... > > Command syntax: > myscript -o[exension] other_arguments > where; extension can be 'exe', 'txt', 'pdf', 'ppt' etc. > > > Now to parse this, I am doing following... > > parser.add_option("-oexe', dest=exe_file...) > parser.a

Re: optparse: best way

2010-06-08 Thread Michele Simionato
On Jun 8, 10:38 am, hiral wrote: > Hi, > > I am using optparser to do following... > > Command syntax: > myscript -o[exension] other_arguments >     where; extension can be 'exe', 'txt', 'pdf', 'ppt' etc. > > Now to parse this, I am doing following... > > parser.add_option("-oexe', dest=exe_file..

Re: optparse: best way

2010-06-08 Thread Ben Finney
ix including the full-stop (‘.’) character. What your example suggests is that you want to have an option, “-o”, which takes an argument which is the output suffix. I'd prefer to also have a long option with a descriptive name for the same purpose. So here's my interpretation::

Re: optparse: best way

2010-06-08 Thread Jean-Michel Pichavant
ay to parse these kind of options. Thank you in advance. Here's a solution: import optparse class Process: PREFIX = 'dispatch_' @staticmethod def undef(): print 'unsupported file type' @staticmethod def dispatch_exe(): print 'Hello exe

Re: optparse: best way

2010-06-08 Thread Thomas Jollans
On 2010-06-08 10:38, hiral wrote: > Hi, > > I am using optparser to do following... > > Command syntax: > myscript -o[exension] other_arguments > where; extension can be 'exe', 'txt', 'pdf', 'ppt' etc. > > > Now to parse this, I am doing following... > > parser.add_option("-oexe', dest=exe_file

optparse: best way

2010-06-08 Thread hiral
Hi, I am using optparser to do following... Command syntax: myscript -o[exension] other_arguments where; extension can be 'exe', 'txt', 'pdf', 'ppt' etc. Now to parse this, I am doing following... parser.add_option("-oexe', dest=exe_file...) parser.add_option("-otxt', dest=txt_file...) par

optparse print_help question

2010-02-06 Thread mark.wendell
Is there a way to use the optparser parser.print_help() so that it ONLY prints out the options, and NOT the usage? thanks -- http://mail.python.org/mailman/listinfo/python-list

Re: Print Options of optparse

2009-12-16 Thread Steven D'Aprano
On Wed, 16 Dec 2009 23:10:26 -0800, Enchanter wrote: > I am learning Python and uising optparse to handle command-line options. > But I am not sure who to print the options' content below: > > . > > options, args = parser.parse_args() Is there a reason why print op

Re: testing command line scripts that use optparse

2009-12-04 Thread Jean-Michel Pichavant
n2.6/lib/python2.6/optparse.py", line 1578, in error self.exit(2, "%s: error: %s\n" % (self.get_prog_name(), msg)) File "/usr/local/python2.6/lib/python2.6/optparse.py", line 1568, in exit sys.exit(status) SystemExit: 2 >> begin captured

testing command line scripts that use optparse

2009-12-03 Thread Peter
ython2.6/optparse.py", line 1578, in error self.exit(2, "%s: error: %s\n" % (self.get_prog_name(), msg)) File "/usr/local/python2.6/lib/python2.6/optparse.py", line 1568, in exit sys.exit(status) SystemExit: 2 >> begin captured stdout <<

Re: Validating positional arguments in optparse

2009-10-23 Thread Robert Kern
On 2009-10-23 05:54 AM, Filip Gruszczyński wrote: That being said, I still stick with optparse. I prefer the dogmatic interface that makes all my exe use the exact same (POSIX) convention. I really don't care about writing /file instead of --file I would like to keep POSIX convention too

Re: Validating positional arguments in optparse

2009-10-23 Thread Filip Gruszczyński
> That being said, I still stick with optparse. I prefer the dogmatic > interface that makes all my exe use the exact same (POSIX) convention. I > really don't care about writing /file instead of --file I would like to keep POSIX convention too, but just wanted OptionParser to do

Re: Validating positional arguments in optparse

2009-10-23 Thread Jean-Michel Pichavant
Filip Gruszczyński wrote: optparse module is quite smart, when it comes to validating options, like assuring, that certain option must be an integer. However, I can't find any information about validating, that positional arguments were provided and I can't find methods, that w

Validating positional arguments in optparse

2009-10-23 Thread Filip Gruszczyński
optparse module is quite smart, when it comes to validating options, like assuring, that certain option must be an integer. However, I can't find any information about validating, that positional arguments were provided and I can't find methods, that would allow defining positional a

Re: optparse, allowing both --foo and foo=99?

2009-10-16 Thread Jean-Michel Pichavant
Jean-Michel Pichavant wrote: Carl Banks wrote: On Oct 15, 10:29 pm, Mark Harrison wrote: What's the magic to allow this? If the value is not specified I would like to use the default value of 1. import optparse p=optparse.OptionParser() p.add_option("--debug") (opts, args)

Re: optparse, allowing both --foo and foo=99?

2009-10-16 Thread Jean-Michel Pichavant
Carl Banks wrote: On Oct 15, 10:29 pm, Mark Harrison wrote: What's the magic to allow this? If the value is not specified I would like to use the default value of 1. import optparse p=optparse.OptionParser() p.add_option("--debug") (opts, args) = p.parse_args(['--deb

optparse, allowing both --foo and foo=99?

2009-10-16 Thread Mark Harrison
What's the magic to allow this? If the value is not specified I would like to use the default value of 1. import optparse p=optparse.OptionParser() p.add_option("--debug") (opts, args) = p.parse_args(['--debug=22']); print opts (opts, args) = p.parse_args(['--deb

Re: optparse, allowing both --foo and foo=99?

2009-10-16 Thread Carl Banks
On Oct 15, 10:29 pm, Mark Harrison wrote: > What's the magic to allow this?  If the value is not specified I > would like to use the default value of 1. > > import optparse > p=optparse.OptionParser() > p.add_option("--debug") > > (opts, args) = p.parse_a

RE: getop or optparse with option with spaces?

2009-06-10 Thread David Shapiro
Unfortunately, I had no luck installing argparse, which is really confusing because I would need to use some old version pre-optik to use I think. The Jython I use is like python 2.2.3. I spent all of yesterday trying to get either getopt, argparse, or optparse to work. Even with optparse I

Re: getop or optparse with option with spaces?

2009-06-10 Thread Javier Collado
l with options that have > spaces in them.  I am using jython, which is the same I think as python > 2.2.3.   I feebly tried to use optparse and argparse with no success (got > gettext, locale, and optparse).   The code is as follows: > >    try: >        (o

getop or optparse with option with spaces?

2009-06-10 Thread David Shapiro
Hello, I have been trying to find an example of how to deal with options that have spaces in them. I am using jython, which is the same I think as python 2.2.3. I feebly tried to use optparse and argparse with no success (got gettext, locale, and optparse). The code is as follows

Re: optparse question, passing unknown flags to subprocess

2009-05-20 Thread Robert Kern
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

optparse question, passing unknown flags to subprocess

2009-05-20 Thread Joseph Garvin
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

Re: optparse options

2009-05-20 Thread Mike Kazantsev
Ben Finney wrote: > icarus writes: > >> parser = optparse.OptionParser(usage="%prog [-p dir] [--part=dir] ", >> version="%prog 1.0") >> >> parser.add_option( "-p", "--part", dest="directory", >>help="process target directory", metavar="dir") >> (options, arg

Re: optparse options

2009-05-19 Thread Ben Finney
icarus writes: > parser = optparse.OptionParser(usage="%prog [-p dir] [--part=dir] ", > version="%prog 1.0") > > parser.add_option( "-p", "--part", dest="directory", > help="process target directory", metavar="dir") > (options, args) = parser.parse_args(

Re: optparse options

2009-05-19 Thread Robert Kern
On 2009-05-19 16:07, icarus wrote: Why do I need to put two options for this script to print the path? if I just specify the option and argument... $ python

optparse options

2009-05-19 Thread icarus
Why do I need to put two options for this script to print the path? if I just specify the option and argument... $ python

  1   2   3   4   >