optparse eats $

Peter Otten __peter__ at web.de
Tue Apr 19 16:36:58 EDT 2011


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)
> 
> 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
$




More information about the Python-list mailing list