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

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top