By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,995 Members | 1,217 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,995 IT Pros & Developers. It's quick & easy.

How to send negative value arguments for command line application?

P: 3
I have created a piece of python code; however, I want to execute it from the command line with some arguments and options. What I have so far works ok (with the exception that i CANNOT enter in negative values for the arguments -- and i need to be able to!) How can i better write this code?

What i enter on the command line:

C:\...> arg1 arg2 arg3 -o filename -p filename -q filename (this is 3 arguments and 3 options)

What my code does (works with exception of negatives):

import sys




Help with this please...Again, I want to correctly do the arguments and options on the command line and be able to input negative values for an argument if needed. Again, what i have works (except for negative values)....anyone know a better way?
Dec 2 '10 #1
Share this Question
Share on Google+
2 Replies

Expert 100+
P: 624
AFAIK there is no way to tell the difference between an option and a negative number, so you would have to either assume that non-options are negative numbers, or check with isdigit(), or come up with something like -neg and then the negative number.
Dec 2 '10 #2

Expert 100+
P: 624
If you come up with a good solution to this please post it as this is something that comes up from time to time.
Dec 3 '10 #3

Post your reply

Sign in to post your reply or Sign up for a free account.