optparse eats $

Michael Kent mrmakent at gmail.com
Tue Apr 19 22:39:44 CEST 2011

Try this on your *nix command line: echo ">$100"

On a *nix command line, the '$1' part of ">$100" will be seen as 'give me the value of the shell variable "1"', and since it has no value, will result in an empty string.  So it's not optparse, or Python, because the literal string you intend to pass as a command line argument to your Python script never has a chance of getting there.  Try escaping the '$' with a backslash on the command line.

More information about the Python-list mailing list