Re: python copy selected lines from one file to another using argparse or getopt

2014-01-08 Thread Dave Angel
On Wed, 8 Jan 2014 13:51:40 -0800 (PST), sagarnild...@gmail.com wrote: I am trying to write a program in python which searches for user specified words in a txt file and copies the selected lines containing that word into another file. John Gordon has given you a good start on argument parsing

Re: python copy selected lines from one file to another using argparse or getopt

2014-01-08 Thread Mark Lawrence
. This excludes the word "abc" and search for "exception". But I don't know how to: Include multiple search word and exclude words How to denote them by -e and -s. I have seen the argparse and the getopt tutorial. But there's no tutorial on this specific topic. Ple

Re: python copy selected lines from one file to another using argparse or getopt

2014-01-08 Thread John Gordon
In sagarnild...@gmail.com writes: > But I don't know how to: > Include multiple search word and exclude words > How to denote them by -e and -s. I have seen the argparse and the getopt > tutorial. But there's no tutorial on this specific topic. This should help you ge

python copy selected lines from one file to another using argparse or getopt

2014-01-08 Thread sagarnildass
rch for "exception". But I don't know how to: Include multiple search word and exclude words How to denote them by -e and -s. I have seen the argparse and the getopt tutorial. But there's no tutorial on this specific topic. Please can somebody help me by modifying my code or wr

Re: Newbie -> NameError: getopt

2011-04-04 Thread R. Tyler Croy
gt; File "/home/oracle/wlsuserconfigfiles/./Health_Check_Servers.py", line > 80, in > ? > File "/home/oracle/wlsuserconfigfiles/./Health_Check_Servers.py", line > 22, in > main > NameError: getopt > > I thought I was importing the "getopt" as shown belo

Newbie -> NameError: getopt

2011-04-04 Thread Mustafa Cayci
ot;/home/oracle/wlsuserconfigfiles/./Health_Check_Servers.py", line 22, in main NameError: getopt I thought I was importing the "getopt" as shown below. Thanks for you help in advance, Mustafa #Conditionally import wlstModule only when script is executed with jython if __name__ == &#

Re: getopt question

2010-04-09 Thread Sean DiZazzo
s. > > Raphael > ----- > > [testGetOpt.py< 1K ]#!/usr/bin/env python > import sys > import getopt > > try: >     opts, args = getopt.getopt(sys.argv[1:], 'ab') > except getopt.error: >     print 

getopt question

2010-04-09 Thread Raphael Mayoraz
; is not in the argument given in getopt.getopt, but it doesn't. What am I doing wrong ? Using python 2.6.4 on WindowXP. Thanks. Raphael - #!/usr/bin/env python import sys import getopt try: opts, args = getopt.getopt(sys.argv[1:

getopt question

2010-04-09 Thread Raphael Mayoraz
Hello, I have some trouble to make getopt.getopt work and the way I want (and is described in the documentation). Attached is very small script to reproduce my problem. If running: > python testGetOpt.py -a junk1 -b junk2 everything is ok > python testGetOpt.py -c junk1 ok too: I get the 'In

Re: getopt not raising exception

2010-01-10 Thread Emmanuel Surleau
> Matt Nordhoff wrote: > > BTW: Checked out optparse? It's bigger and sexier! If you're doing things with positional arguments, you should consider using argparse (http://argparse.googlecode.com/svn/tags/r101/doc/index.html). It's like optparse, but (much) better. Cheers, Emm -- http://mail.

Re: getopt not raising exception

2010-01-10 Thread Matthew Lear
Matt Nordhoff wrote: > BTW: Checked out optparse? It's bigger and sexier! Thanks for the tip. Works a treat. -- Matt -- http://mail.python.org/mailman/listinfo/python-list

Re: getopt not raising exception

2010-01-10 Thread Matt Nordhoff
Matthew Lear wrote: > Hello, > > I'm having problems getting getopt to function correctly. Basically, no > exception is being raised if no argument is passed to the code snippet > below. I've read the Python documentation and tried example code from > various s

getopt not raising exception

2010-01-10 Thread Matthew Lear
Hello, I'm having problems getting getopt to function correctly. Basically, no exception is being raised if no argument is passed to the code snippet below. I've read the Python documentation and tried example code from various sources which should cause an exception, only they don&#x

Re: getopt code NameError exception on logTail.py

2009-07-17 Thread Michael Torrie
LoD MoD wrote: > In this instance the trackback was somewhat unhelpful.There problem was > here: > >file = open(filename, 'r') > > should be > >file = open(a, 'r') > > args should be passed within the getopt riff We

Re: getopt code NameError exception on logTail.py

2009-07-17 Thread LoD MoD
In this instance the trackback was somewhat unhelpful.There problem was here: file = open(filename, 'r') should be file = open(a, 'r') args should be passed within the getopt riff On Fri, Jul 17, 2009 at 11:08 AM, MRAB wrote: > LoD MoD wrote: &

Re: getopt code NameError exception on logTail.py

2009-07-17 Thread MRAB
LoD MoD wrote: I am having trouble extending my option parsing. Any help is appreciated: import sys import getopt import time def tail(file): while 1: where = file.tell() line = file.readline() if not line: time.sleep(1) file.seek(where

getopt code NameError exception on logTail.py

2009-07-17 Thread LoD MoD
I am having trouble extending my option parsing. Any help is appreciated: import sys import getopt import time def tail(file): while 1: where = file.tell() line = file.readline() if not line: time.sleep(1) file.seek(where

Re: python and getopt and spaces in option

2009-06-10 Thread Jorgen Grahn
if (key in ("-q", "--testTableName")): ... > The one that gives me trouble is with the -q option, because it can > look like: -q "SQL 1 TABLE". It returns back just SQL. How do I get > it to return the whole thing that is in double quotes?

python and getopt and spaces in option

2009-06-09 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: try

Re: getopt index out of range

2009-02-11 Thread Matthew Sacks
Keep your threadiquette to yourself. On Wed, Feb 11, 2009 at 1:48 PM, John Machin wrote: > On Feb 11, 6:16 am, Matthew Sacks wrote: >> Hi List, >> I am getting an index out of range error when trying to parse with getopt. >> Probably something simple. Any sugges

Re: getopt index out of range

2009-02-11 Thread Matthew Sacks
Perhaps you can give me a call privately and I will explain it to you. Regards, Matthew On Wed, Feb 11, 2009 at 1:48 PM, John Machin wrote: > On Feb 11, 6:16 am, Matthew Sacks wrote: >> Hi List, >> I am getting an index out of range error when trying to parse with getopt. >&g

Re: getopt index out of range

2009-02-11 Thread John Machin
On Feb 11, 6:16 am, Matthew Sacks wrote: > Hi List, > I am getting an index out of range error when trying to parse with getopt. > Probably something simple. Any suggestions are appreciated > > optlist, args = getopt.getopt(sys.argv[1:], 'h', ['connectPassword=&

Re: getopt index out of range

2009-02-11 Thread Matthew Sacks
an index out of range error when trying to parse with >>> getopt. >>> Probably something simple. Any suggestions are appreciated >>> >>> optlist, args = getopt.getopt(sys.argv[1:], 'h', ['connectPassword=', >>> 'adminServerURL=', &

Re: getopt index out of range

2009-02-11 Thread MRAB
Steve Holden wrote: Matthew Sacks wrote: Hi List, I am getting an index out of range error when trying to parse with getopt. Probably something simple. Any suggestions are appreciated optlist, args = getopt.getopt(sys.argv[1:], 'h', ['connectPassword=', 'adminServerU

Re: getopt index out of range

2009-02-11 Thread Steve Holden
Matthew Sacks wrote: > Hi List, > I am getting an index out of range error when trying to parse with getopt. > Probably something simple. Any suggestions are appreciated > > optlist, args = getopt.getopt(sys.argv[1:], 'h', ['connectPassword=', > 'admin

Re: optparse versus getopt

2009-02-11 Thread Pete Forman
Robert Kern writes: >> is there some way i can force the import based on the the absolute >> path to the module? > > Better would be for you to copy the optparse.py module onto your > Jython's import path. I'm not particularly familiar with the details > of Jython, so you will need to consult

Re: getopt

2009-02-11 Thread John Machin
specify *all* short options that you will accept, whether they are no-value or value options; otherwise you would have to do your own checking for unacceptable options > This seems to make things a bit more difficult considering unless I > use the GNU style getopt all arguments are require

Re: getopt

2009-02-10 Thread Matthew Sacks
I didn't realize that the no-value arguments, -b, -h, etc are required? This seems to make things a bit more difficult considering unless I use the GNU style getopt all arguments are required to be passed? I could be mistaken. I will have a look at what you have posted here and report my re

Re: getopt

2009-02-10 Thread John Machin
On Feb 11, 4:36 pm, Matthew Sacks wrote: > The documentation leaves lack for want, especially the examples. You had two problems: (1) str(passedArgs): The docs make it plain that "args" is a list, not a str instance: """args is the argument list to be parsed, without the leading reference to the

Re: getopt

2009-02-10 Thread John Machin
On Feb 11, 12:25 pm, John Machin wrote: > On Feb 11, 12:12 pm, Matthew Sacks wrote: > > > if anyone can have a look at this code and offer suggestions i would > > appreciate it. > > i am forced to use getopt, so i cant use something good like optparse > > > pass

Re: getopt

2009-02-10 Thread Matthew Sacks
The documentation leaves lack for want, especially the examples. On Tue, Feb 10, 2009 at 5:25 PM, John Machin wrote: > On Feb 11, 12:12 pm, Matthew Sacks wrote: >> if anyone can have a look at this code and offer suggestions i would >> appreciate it. >> i am forced to use

Re: getopt

2009-02-10 Thread John Machin
On Feb 11, 12:12 pm, Matthew Sacks wrote: > if anyone can have a look at this code and offer suggestions i would > appreciate it. > i am forced to use getopt, so i cant use something good like optparse > > passedArgs = sys.argv[1:] > optlist, args = getopt.get

getopt

2009-02-10 Thread Matthew Sacks
if anyone can have a look at this code and offer suggestions i would appreciate it. i am forced to use getopt, so i cant use something good like optparse passedArgs = sys.argv[1:] optlist, args = getopt.getopt(str(passedArgs), ["connectPassword=", "adminServerURL=", "acti

Re: optparse versus getopt

2009-02-10 Thread Robert Kern
On 2009-02-10 17:32, Matthew Sacks wrote: its a debian package. 2.5 importing optparse works with interactive python, but not through the jython interpreter i an using. Ah, yes. The current version of Jython is still based off of Python 2.2 whereas optparse was introduced in Python 2.3. is

Re: optparse versus getopt

2009-02-10 Thread Matthew Sacks
its a debian package. 2.5 importing optparse works with interactive python, but not through the jython interpreter i an using. is there some way i can force the import based on the the absolute path to the module? On Tue, Feb 10, 2009 at 1:48 PM, Robert Kern wrote: > On 2009-02-10 15:42, Matthe

Re: optparse versus getopt

2009-02-10 Thread Robert Kern
On 2009-02-10 15:42, Matthew Sacks wrote: it seems as if optparse isn't in my standard library. How did you install your Python? It has been part of the standard library for a very long time. is there a way to add a lib like ruby gems? http://docs.python.org/install/index.html But optpar

Re: optparse versus getopt

2009-02-10 Thread Matthew Sacks
it seems as if optparse isn't in my standard library. is there a way to add a lib like ruby gems? On Tue, Feb 10, 2009 at 1:38 PM, Tim Chase wrote: > Matthew Sacks wrote: >> >> does anyone have any arguments against optparse vs getopt > > I've found that the

Re: optparse versus getopt

2009-02-10 Thread Tim Chase
Matthew Sacks wrote: does anyone have any arguments against optparse vs getopt I've found that the optparse module beats getopt on *every* aspect except in the event that you have experience with the C getopt libraries *and* just want something that behaves like those libraries. Opt

Re: optparse versus getopt

2009-02-10 Thread Robert Kern
On 2009-02-10 15:06, Matthew Sacks wrote: does anyone have any arguments against optparse vs getopt As the getopt docs say: "A more convenient, flexible, and powerful alternative is the optparse module." I have found all three statements to be true. But I've found argp

optparse versus getopt

2009-02-10 Thread Matthew Sacks
does anyone have any arguments against optparse vs getopt -- http://mail.python.org/mailman/listinfo/python-list

getopt index out of range

2009-02-10 Thread Matthew Sacks
Hi List, I am getting an index out of range error when trying to parse with getopt. Probably something simple. Any suggestions are appreciated optlist, args = getopt.getopt(sys.argv[1:], 'h', ['connectPassword=', 'adminServerURL=', 'action=', 'targets=

Re: Pythonically extract data from a list of tuples (getopt)

2008-04-23 Thread Mike Kent
You could use http://docs.python.org/lib/module-optparse.html -- http://mail.python.org/mailman/listinfo/python-list

Pythonically extract data from a list of tuples (getopt)

2008-04-23 Thread Mark Reed
So the return value from getopt.getopt() is a list of tuples, e.g. >>> import getopt >>> opts = getopt.getopt('-a 1 -b 2 -a 3'.split(), 'a:b:')[0]; opts [('-a', '1'), ('-b', '2'), ('-a', '3')] what

Re: getopt with negative numbers?

2007-09-29 Thread Carl Banks
On Sep 29, 7:58 pm, Ben Finney <[EMAIL PROTECTED]> wrote: > Carl Banks <[EMAIL PROTECTED]> writes: > > On Sep 28, 6:19 pm, Ben Finney <[EMAIL PROTECTED]> > > wrote: > > > Steven Bethard <[EMAIL PROTECTED]> writes: > > > > A user shouldn't have to go out of their way to specify regular > > > > numbe

Re: getopt with negative numbers?

2007-09-29 Thread Ben Finney
Carl Banks <[EMAIL PROTECTED]> writes: > On Sep 28, 6:19 pm, Ben Finney <[EMAIL PROTECTED]> > wrote: > > Steven Bethard <[EMAIL PROTECTED]> writes: > > > A user shouldn't have to go out of their way to specify regular > > > numbers on the command line, regardless of whether they're > > > positive

Re: getopt with negative numbers?

2007-09-28 Thread Carl Banks
On Sep 28, 6:19 pm, Ben Finney <[EMAIL PROTECTED]> wrote: > Steven Bethard <[EMAIL PROTECTED]> writes: > > A user shouldn't have to go out of their way to specify regular > > numbers on the command line, regardless of whether they're positive > > or negative. > > A user shouldn't have to go out of

Re: getopt with negative numbers?

2007-09-28 Thread Ben Finney
Steven Bethard <[EMAIL PROTECTED]> writes: > A user shouldn't have to go out of their way to specify regular > numbers on the command line, regardless of whether they're positive > or negative. A user shouldn't have to go out of their way to know whether what they type on a command line will be t

Re: getopt with negative numbers?

2007-09-28 Thread Steven Bethard
Casey wrote: > Ben Finney wrote: >> I believe they shouldn't because the established interface is that a >> hyphen always introduced an option unless (for those programs that >> support it) a '--' option is used, as discussed. > > Not "THE" established interface; "AN" established interface. There

Re: getopt with negative numbers?

2007-09-28 Thread Casey
921" as a negative integer and not abort the program with some obscure error about option 921 not being known. > > > But I think it is a simple and clever hack and still allows getopt > > or optparse to function normally. > > Except that they *don't* function normall

Re: getopt with negative numbers?

2007-09-28 Thread Neal Becker
Ben Finney wrote: > Casey <[EMAIL PROTECTED]> writes: > >> Well, it is a hack and certainly not as clean as having getopt or >> optparse handle this natively (which I believe they should). > > I believe they shouldn't because the established interface is t

Re: getopt with negative numbers?

2007-09-27 Thread Ben Finney
Casey <[EMAIL PROTECTED]> writes: > Well, it is a hack and certainly not as clean as having getopt or > optparse handle this natively (which I believe they should). I believe they shouldn't because the established interface is that a hyphen always introduced an option unless (f

Re: getopt with negative numbers?

2007-09-27 Thread Casey
On Sep 27, 7:57 pm, Neal Becker <[EMAIL PROTECTED]> wrote: > One person's "brilliant" is another's "kludge". Well, it is a hack and certainly not as clean as having getopt or optparse handle this natively (which I believe they should). But I think it is a

Numeric command-line options vs. negative-number arguments (was: getopt with negative numbers?)

2007-09-27 Thread Ben Finney
Steven Bethard <[EMAIL PROTECTED]> writes: > In most cases, argparse (http://argparse.python-hosting.com/) > supports negative numbers right out of the box, with no need to use > '--': > > >>> import argparse > >>> parser = argparse.ArgumentParser() > >>> parser.add_argument('-a', typ

Re: getopt with negative numbers?

2007-09-27 Thread Neal Becker
Casey wrote: > On Sep 27, 2:21 pm, "J. Clifford Dyer" <[EMAIL PROTECTED]> wrote: >> If you can access the argument list manually, you could scan it for a >> negative integer, and then insert a '--' argument before that, >> if needed, before passing

Re: getopt with negative numbers?

2007-09-27 Thread Steven Bethard
Casey wrote: > Is there an easy way to use getopt and still allow negative numbers as > args? [snip] > Alternatively, does optparse handle this? Peter Otten wrote: > optparse can handle options with a negative int value; "--" can be used to > signal that no

Re: getopt with negative numbers?

2007-09-27 Thread Casey
On Sep 27, 2:21 pm, "J. Clifford Dyer" <[EMAIL PROTECTED]> wrote: > If you can access the argument list manually, you could scan it for a > negative integer, > and then insert a '--' argument before that, if needed, before passing it to > getopt/optparse. &

Re: getopt with negative numbers?

2007-09-27 Thread Casey
On Sep 27, 2:21 pm, "J. Clifford Dyer" <[EMAIL PROTECTED]> wrote: > If you can access the argument list manually, you could scan it for a > negative integer, and then insert a '--' argument before that, > if needed, before passing it to getopt/optparse. Then

Re: getopt with negative numbers?

2007-09-27 Thread Nanjundi
On Sep 27, 1:34 pm, Peter Otten <[EMAIL PROTECTED]> wrote: ... > >>> args > > ['-123'] > > Without the "--" arg you will get an error: > > >>> parser.parse_args(["-123"]) > > Usage: [options] > > : error: no such option: -1 > $ > > Peter Passing -a-123 works >>> options, args = parser.parse_args(

Re: getopt with negative numbers?

2007-09-27 Thread J. Clifford Dyer
If you can access the argument list manually, you could scan it for a negative integer, and then insert a '--' argument before that, if needed, before passing it to getopt/optparse. Then you wouldn't have to worry about it on the command line. Cheers, Cliff On Thu, Sep 27

Re: getopt with negative numbers?

2007-09-27 Thread Peter Otten
Casey wrote: > On Sep 27, 1:34 pm, Peter Otten <[EMAIL PROTECTED]> wrote: >> optparse can handle options with a negative int value; "--" can be used >> to signal that no more options will follow: > > Thanks, Peter. getopt supports the POSIX "--&quo

Re: getopt with negative numbers?

2007-09-27 Thread Casey
On Sep 27, 1:34 pm, Peter Otten <[EMAIL PROTECTED]> wrote: > optparse can handle options with a negative int value; "--" can be used to > signal that no more options will follow: Thanks, Peter. getopt supports the POSIX "--" end of options indicator as well, but

Re: getopt with negative numbers?

2007-09-27 Thread Peter Otten
Casey wrote: > Is there an easy way to use getopt and still allow negative numbers as > args? I can easily write a workaround (pre-process the tail end of > the arguments, stripping off any non-options including negative > numbers into a separate sequence and ignore the (now empt

getopt with negative numbers?

2007-09-27 Thread Casey
Is there an easy way to use getopt and still allow negative numbers as args? I can easily write a workaround (pre-process the tail end of the arguments, stripping off any non-options including negative numbers into a separate sequence and ignore the (now empty) args list returned by getopt, but

Re: getopt or optparse options/arguments wrapping?

2007-03-18 Thread Steven Bethard
Rocky Zhou wrote: > .dirs .files is just a snapshot of the current directories, which can > be used to delete-outdated files when restoring. Here I used absolute > path by using tar's -P parameter. When fs_rstore, it will do this: > command = "tar -xpz -P -f %s.tgz -T %s" % (archive, self.t_files)

Re: getopt or optparse options/arguments wrapping?

2007-03-18 Thread Rocky Zhou
Well, I think I must have more explanation on my script. The script's usage is like this: ~# fs_backup Lack of backup identity name program usage: fs_backup [OPTIONS] $identity OPTIONS: -a|--append [t/x[L]:$path, append 1 dir or file to $identity t/x: include/exclude list, as -T/-X

Re: getopt or optparse options/arguments wrapping?

2007-03-16 Thread Steven Bethard
Rocky Zhou wrote: > I wonder is there any way to make the wrapper program can wrap options > && arguments for the the subprocess/command the wrapper will > execute? by getopt or optparse module? [snip] > I need this because I now have finished a fs_backup script written

getopt or optparse options/arguments wrapping?

2007-03-16 Thread Rocky Zhou
I wonder is there any way to make the wrapper program can wrap options && arguments for the the subprocess/command the wrapper will execute? by getopt or optparse module? This is something like the shell script like this: optwrap="" while [ $# -gt 0 ]; do case $1 in

Re: ImportError: No module named getopt

2006-11-23 Thread prashant
thanks a lot that helped... Fredrik Lundh wrote: > "prashant" wrote: > > > I am actually using Cygwin to run a python script. > > I have python 2.5 installed. But when i ran the command mentioned by > > you... I see that it is looking in the wrong directories... how can i > > change these look up

Re: ImportError: No module named getopt

2006-11-23 Thread Fredrik Lundh
"prashant" wrote: > I am actually using Cygwin to run a python script. > I have python 2.5 installed. But when i ran the command mentioned by > you... I see that it is looking in the wrong directories... how can i > change these look up directories? is PYTHONHOME perhaps set to the wrong thing?

Re: ImportError: No module named getopt

2006-11-23 Thread prashant
te: > > >I am running a python script which has the line > > > > import getopt, sys, os, re, string > > > > And i get the error > > > > ImportError: No module named getopt > > > > Could you please point out a possible solution for

Re: ImportError: No module named getopt

2006-11-23 Thread Fredrik Lundh
"prashant" wrote: >I am running a python script which has the line > > import getopt, sys, os, re, string > > And i get the error > > ImportError: No module named getopt > > Could you please point out a possible solution for this? looks like a broken ins

ImportError: No module named getopt

2006-11-23 Thread prashant
I am running a python script which has the line import getopt, sys, os, re, string And i get the error ImportError: No module named getopt Could you please point out a possible solution for this? -- http://mail.python.org/mailman/listinfo/python-list

Re: How to handle wrong input in getopt package in Python?

2006-08-25 Thread skip
Daniel> getopt.GetoptError: option --imageDir requires argument Which is precisely what the getopt module should do. Daniel> Is there any method in getopt or Python that I could easily Daniel> check the validity of each command line input parameter? Getopt already did the

How to handle wrong input in getopt package in Python?

2006-08-25 Thread Daniel Mark
Hello all: I am using getopt package in Python and found a problem that I can not figure out an easy to do . // Correct input D:\>python AddArrowOnImage.py --imageDir=c:/ // Incorrect input D:\>python AddArrowOnImage.py --imageDi Traceback (most recent call last): File "AddArro

Re: getopt and options with multiple arguments

2005-12-20 Thread Tom Anderson
On Mon, 19 Dec 2005, [EMAIL PROTECTED] wrote: > I want to be able to do something like: > > myscript.py * -o outputfile > > and then have the shell expand the * as usual, perhaps to hundreds of > filenames. But as far as I can see, getopt can only get one argument > wit

Re: getopt and options with multiple arguments

2005-12-19 Thread Steven D'Aprano
ls, the shell will already have expanded the * and myscript.py will never see the asterisk. > But as far as I can see, getopt can only get one argument > with each option. The getopt module has two main functions you probably want to call. getopt.getopt expects options like -o arg follow

Re: getopt and options with multiple arguments

2005-12-19 Thread PoD
On Mon, 19 Dec 2005 02:29:41 -0800, [EMAIL PROTECTED] wrote: > I want to be able to do something like: > > myscript.py * -o outputfile > > and then have the shell expand the * as usual, perhaps to hundreds of > filenames. But as far as I can see, getopt can only get one ar

Re: getopt and options with multiple arguments

2005-12-19 Thread Simon Brunning
On 19 Dec 2005 02:29:41 -0800, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > I want to be able to do something like: > > myscript.py * -o outputfile > > and then have the shell expand the * as usual, perhaps to hundreds of > filenames. But as far as I can see, getopt c

getopt and options with multiple arguments

2005-12-19 Thread [EMAIL PROTECTED]
I want to be able to do something like: myscript.py * -o outputfile and then have the shell expand the * as usual, perhaps to hundreds of filenames. But as far as I can see, getopt can only get one argument with each option. In the above case, there isn't even an option string before the *

Re: python getopt functionality

2005-10-03 Thread Micah Elliott
On Oct 03, M.N.A.Smadi wrote: > It is not clear to me if i can define `mandatory' options? That sounds > strange but let say that the command `requires ' a value for -z or > --zoo (either or should be find but one and only one of them MUST be > present). Can i do that with resorting to using if st

Re: python getopt functionality

2005-10-03 Thread M.N.A.Smadi
It is not clear to me if i can define `mandatory' options? That sounds strange but let say that the command `requires ' a value for -z or --zoo (either or should be find but one and only one of them MUST be present). Can i do that with resorting to using if statements? thanks moe smadi Fredrik

Re: python getopt functionality

2005-10-03 Thread Michael
M.N.A.Smadi wrote: > I have a perl script that I need to port to python. The script takes > input from the command line. Is there a standard way of processing > command line arguments based on the -flag preceeding the argument? Yes. # pydoc getopt Help on module getopt: NAME

Re: python getopt functionality

2005-10-03 Thread Fredrik Lundh
"M.N.A.Smadi" wrote: > I have a perl script that I need to port to python. The script takes > input from the command line. Is there a standard way of processing > command line arguments based on the -flag preceeding the argument? http://docs.python.org/lib/module-getopt.html http://docs.python.o

python getopt functionality

2005-10-03 Thread M.N.A.Smadi
hi; I have a perl script that I need to port to python. The script takes input from the command line. Is there a standard way of processing command line arguments based on the -flag preceeding the argument? thanks moe smadi -- http://mail.python.org/mailman/listinfo/python-list

Re: getopt: Make argument mandatory

2004-12-16 Thread Kent Johnson
Frans Englich wrote: On Wednesday 15 December 2004 14:07, Diez B. Roggisch wrote: In my use of getopt.getopt, I would like to make a certain parameter mandatory. I know how to specify such that a parameter must have a value if it's specified, but I also want to make the parameter itself mandatory(c

Re: getopt: Make argument mandatory

2004-12-16 Thread Frans Englich
On Wednesday 15 December 2004 14:07, Diez B. Roggisch wrote: > > In my use of getopt.getopt, I would like to make a certain parameter > > mandatory. I know how to specify such that a parameter must have a value > > if it's specified, but I also want to make the parameter itself > > mandatory(combin

Re: getopt: Make argument mandatory

2004-12-15 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Frans Englich wrote: >> > In my use of getopt.getopt, I would like to make a certain parameter >> > mandatory. >> >> Isn't a *mandatory option* a contradiction? Why don't you turn it into an >> argument? You already called it argument in the subject of your post. > > I p

Re: getopt: Make argument mandatory

2004-12-15 Thread Frans Englich
On Wednesday 15 December 2004 20:12, Marc 'BlackJack' Rintsch wrote: > In <[EMAIL PROTECTED]>, Frans Englich > > wrote: > > Hello, > > > > In my use of getopt.getopt, I would like to make a certain parameter > > mandatory. > > Isn't a *mandatory option* a contradiction? Why don't you turn it into

Re: getopt: Make argument mandatory

2004-12-15 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Frans Englich wrote: > > Hello, > > In my use of getopt.getopt, I would like to make a certain parameter > mandatory. Isn't a *mandatory option* a contradiction? Why don't you turn it into an argument? You already called it argument in the subject of your post. Ciao,

Re: getopt: Make argument mandatory

2004-12-15 Thread Diez B. Roggisch
> In my use of getopt.getopt, I would like to make a certain parameter > mandatory. I know how to specify such that a parameter must have a value > if it's specified, but I also want to make the parameter itself > mandatory(combined with a mandatory value, the result is that the user > must specify

Re: getopt: Make argument mandatory

2004-12-15 Thread Fredrik Lundh
sys.exit(common.exitCodes["parameter"]) > Is it possible? afaik, getopt doesn't have any built-in validation features; Python's got more than enough of them already... -- http://mail.python.org/mailman/listinfo/python-list

getopt: Make argument mandatory

2004-12-15 Thread Frans Englich
if opt in ("-V", "--version"): print "Version:", common.version["Runner"] sys.exit() # TODO Can't getopt make an argument mandatory? if configurationFile == "": print "Yo