On 2014-02-11 10:37, luke.gee...@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 <module>
>     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



-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to