Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin3!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.010 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'elif': 0.05; 'odd': 0.07; 'sys': 0.07; 'string': 0.09; 'converted': 0.09; 'literal': 0.09; 'received:67.192': 0.09; 'received:67.192.241': 0.09; 'received:dfw.emailsrvr.com': 0.09; 'valueerror:': 0.09; 'integer.': 0.16; 'sign,': 0.16; 'subject:variable': 0.16; 'wrote:': 0.18; 'trying': 0.19; "skip:' 30": 0.19; 'value.': 0.19; 'command': 0.22; 'import': 0.22; 'print': 0.22; 'header:User- Agent:1': 0.23; 'error': 0.23; 'received:emailsrvr.com': 0.24; 'fine': 0.24; 'question': 0.24; 'received:(smtp server)': 0.26; 'skip:" 30': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; "i'm": 0.30; 'gary': 0.31; 'file': 0.32; 'quite': 0.32; '(most': 0.33; 'skip:# 10': 0.33; 'trouble': 0.34; 'message.': 0.35; "can't": 0.35; 'something': 0.35; 'but': 0.35; "didn't": 0.36; 'being': 0.38; 'to:addr:python-list': 0.38; 'recent': 0.39; 'does': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'is.': 0.60; 'tell': 0.60; 'course': 0.61; 'email addr:gmail.com': 0.63; 'such': 0.63; 'sum': 0.64; 'invalid': 0.68; 'manner': 0.72; 'url:%1': 0.72; 'us,': 0.73; '10:': 0.84; 'url:tl': 0.84; 'url:translate': 0.84; 'luck': 0.93 X-Virus-Scanned: OK Date: Tue, 11 Feb 2014 10:55:59 -0800 From: Gary Herron User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Flag control variable References: <5019eb5d-ebda-4417-ab2d-9a58afcdd186@googlegroups.com> In-Reply-To: <5019eb5d-ebda-4417-ab2d-9a58afcdd186@googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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: 40 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1392144984 news.xs4all.nl 2937 [2001:888:2000:d::a6]:57832 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:65945 On 02/11/2014 10:37 AM, luke.geelen@gmail.com wrote: > well i'm trying something else but no luck : > > #!bin/bash/python > import sys > import os > a = int(sys.argv[1]) > sign = (sys.argv[2]) > b = int(sys.argv[3]) > > if sign == '+': > sum = a + b > print a, sign, b, "=", a + b > command1 = "sudo mpg321 'http://translate.google.com/translate_tts?tl=en&q=%s_plus%s_equals%s'" % (a, b, sum) > os.system (command1) > > elif sign == "*": > sum = a * b > print a, sign, b, "=", a * b > 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 + Look at the error message. Carefully! It says, quite clearly, the call to int is being passed a string "Adafruit-Raspberry-Pi-Python-Code", which of course can't be converted to an integer. Now the question is how you ran the program in such a manner that sys.argv[3] has such an odd value. What does your command line look like? You didn't tell us, but that's where the trouble is. Gary Herron