optparse eats $

T

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.add_option('--file', '-f', dest="file", help="Define the active file to analyze", default='', metavar='"<File Path>"')

(options, arguments) = p.parse_args()

print arguments <- What is becoming ['>00']


So, any ideas? Why is including a $ eating both the dollar signa and the 1?
 
J

John Gordon

In said:
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.
 
P

Peter Otten

tazz_ben said:
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.add_option('--file', '-f', dest="file", help="Define the active
file to analyze", default='', metavar='"<File Path>"')

(options, arguments) = p.parse_args()

print arguments <- What is becoming ['>00']


So, any ideas? Why is including a $ eating both the dollar signa and the
1?

It ain't optparse, it's your shell:

$ echo ">$100"
00 $ echo '>$100'
$100
$
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,982
Messages
2,570,189
Members
46,734
Latest member
manin

Latest Threads

Top