Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #3587 > unrolled thread

optparse eats $

Started bytazz_ben <ben@wbpsystems.com>
First post2011-04-19 13:28 -0700
Last post2011-04-19 22:36 +0200
Articles 3 — 3 participants

Back to article view | Back to comp.lang.python


Contents

  optparse eats $ tazz_ben <ben@wbpsystems.com> - 2011-04-19 13:28 -0700
    Re: optparse eats $ John Gordon <gordon@panix.com> - 2011-04-19 20:34 +0000
    Re: optparse eats $ Peter Otten <__peter__@web.de> - 2011-04-19 22:36 +0200

#3587 — optparse eats $

Fromtazz_ben <ben@wbpsystems.com>
Date2011-04-19 13:28 -0700
Subjectoptparse eats $
Message-ID<f315a5f9-b11a-48e8-b5ce-1e72dcabc161@glegroupsg2000goo.googlegroups.com>
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?

[toc] | [next] | [standalone]


#3588

FromJohn Gordon <gordon@panix.com>
Date2011-04-19 20:34 +0000
Message-ID<iokrlh$dfe$1@reader1.panix.com>
In reply to#3587
In <f315a5f9-b11a-48e8-b5ce-1e72dcabc161@glegroupsg2000goo.googlegroups.com> tazz_ben <ben@wbpsystems.com> writes:

> 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.

-- 
John Gordon                   A is for Amy, who fell down the stairs
gordon@panix.com              B is for Basil, assaulted by bears
                                -- Edward Gorey, "The Gashlycrumb Tinies"

[toc] | [prev] | [next] | [standalone]


#3589

FromPeter Otten <__peter__@web.de>
Date2011-04-19 22:36 +0200
Message-ID<iokrp4$7k4$1@solani.org>
In reply to#3587
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
$

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web