Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.048 X-Spam-Evidence: '*H*': 0.91; '*S*': 0.00; 'string': 0.09; 'literal': 0.09; 'operator,': 0.09; 'valueerror:': 0.09; 'python': 0.11; '"*"': 0.16; '-tkc': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'quoted': 0.16; 'subject:variable': 0.16; 'wrote:': 0.18; "skip:' 30": 0.19; 'shell': 0.22; 'fine': 0.24; 'options': 0.25; 'this:': 0.26; 'pass': 0.26; 'header:In-Reply-To:1': 0.27; 'expanding': 0.29; 'fault': 0.31; 'occurs': 0.31; 'file': 0.32; '(most': 0.33; 'charset:us-ascii': 0.36; 'list': 0.37; 'to:addr:python-list': 0.38; 'files': 0.38; 'recent': 0.39; 'quote': 0.39; 'to:addr:python.org': 0.39; 'times': 0.62; 'email addr:gmail.com': 0.63; 'such': 0.63; 'different': 0.65; 'occur': 0.65; 'invalid': 0.68; 'url:%1': 0.72; '10:': 0.84; 'here)': 0.84; 'received:50.22': 0.84; 'url:tl': 0.84; 'url:translate': 0.84 Date: Tue, 11 Feb 2014 12:51:14 -0600 From: Tim Chase To: python-list@python.org Subject: Re: Flag control variable In-Reply-To: <5019eb5d-ebda-4417-ab2d-9a58afcdd186@googlegroups.com> References: <5019eb5d-ebda-4417-ab2d-9a58afcdd186@googlegroups.com> X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - boston.accountservergroup.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tim.thechases.com X-Get-Message-Sender-Via: boston.accountservergroup.com: authenticated_id: tim@thechases.com X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 48 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1392144636 news.xs4all.nl 2910 [2001:888:2000:d::a6]:50223 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:65941 On 2014-02-11 10:37, luke.geelen@gmail.com wrote: > command1 = "sudo mpg321 > 'http://translate.google.com/translate_tts?tl=en&q=%s_times%s_equals%s'" > % (a, b, sum) > > when using * i get > > Traceback (most recent call last): > File "./math+.py", line 6, in > b = int(sys.argv[3]) > ValueError: invalid literal for int() with base 10: > 'Adafruit-Raspberry-Pi-Python-Code' > > i don't understand why b is a problem, it works fine with + This is the fault of your shell (bash perhaps)? Try this: bash$ echo + + bash$ echo * (a list of files in your current directory here) which occurs because of file-globbing. You have a couple options that occur to me: 1) quote the asterisk: bash$ ./mycode.py 3 "*" 2 which will let Python see it without the shell expanding it 2) use a different character/string such as "3 times 2" 3) pass the whole thing as a quoted string and then let Python do the splitting: bash$ ./mycode.py "3 * 2" a, operator, b = argv[1:].split() print(a,b,c) -tkc