Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #65942
| Path | csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.002 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'elif': 0.05; 'debugging': 0.07; 'sys': 0.07; 'arguments': 0.09; 'literal': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'valueerror:': 0.09; 'python': 0.11; '"*"': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'sign,': 0.16; 'subject:variable': 0.16; 'wrote:': 0.18; 'trying': 0.19; "skip:' 30": 0.19; 'import': 0.22; 'shell': 0.22; 'print': 0.22; 'header :User-Agent:1': 0.23; 'directory.': 0.24; 'script.': 0.24; 'fine': 0.24; 'purposes': 0.26; 'header:X-Complaints-To:1': 0.27; "i'm": 0.30; 'file': 0.32; '(most': 0.33; 'skip:# 10': 0.33; 'something': 0.35; 'but': 0.35; 'two': 0.37; 'to:addr:python-list': 0.38; 'recent': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'email addr:gmail.com': 0.63; 'sum': 0.64; 'here': 0.66; 'invalid': 0.68; 'url:%1': 0.72; 'touch': 0.74; "'2',": 0.84; '10:': 0.84; 'url:tl': 0.84; 'url:translate': 0.84; 'luck': 0.93 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Peter Otten <__peter__@web.de> |
| Subject | Re: Flag control variable |
| Date | Tue, 11 Feb 2014 19:51:40 +0100 |
| Organization | None |
| References | <baffb663-4f6d-4580-ac5d-d99b4aaf3c40@googlegroups.com> <5019eb5d-ebda-4417-ab2d-9a58afcdd186@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="ISO-8859-1" |
| Content-Transfer-Encoding | 7Bit |
| X-Gmane-NNTP-Posting-Host | p57bd982e.dip0.t-ipconnect.de |
| User-Agent | KNode/4.7.3 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.6693.1392144693.18130.python-list@python.org> (permalink) |
| Lines | 65 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1392144694 news.xs4all.nl 2934 [2001:888:2000:d::a6]:51341 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:65942 |
Show key headers only | View raw
luke.geelen@gmail.com wrote: > well i'm trying something else but no luck : > > #!bin/bash/python Hm. > import sys > import os For debugging purposes put the line print sys.argv here to see what arguments are passed to the script. When you type $ python script.py 2 * 2 in the shell the "*" sign is replaced with all items in the current directory. To avoid that you have to escape, i. e. prepend a backslash: $ python script.py 2 \* 2 To illustrate: $ touch one two three $ ls one three two $ python -c 'import sys; print sys.argv' 2 + 2 ['-c', '2', '+', '2'] $ python -c 'import sys; print sys.argv' 2 * 2 ['-c', '2', 'one', 'three', 'two', '2'] $ python -c 'import sys; print sys.argv' 2 \* 2 ['-c', '2', '*', '2'] > 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 <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 +
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Flag control variable luke.geelen@gmail.com - 2014-02-11 09:29 -0800
Re: Flag control variable Larry Martell <larry.martell@gmail.com> - 2014-02-11 12:44 -0500
Re: Flag control variable Peter Otten <__peter__@web.de> - 2014-02-11 18:46 +0100
Re: Flag control variable luke.geelen@gmail.com - 2014-02-11 10:00 -0800
Re: Flag control variable luke.geelen@gmail.com - 2014-02-11 10:16 -0800
Re: Flag control variable Tim Chase <python.list@tim.thechases.com> - 2014-02-11 12:32 -0600
Re: Flag control variable luke.geelen@gmail.com - 2014-02-11 10:37 -0800
Re: Flag control variable Tim Chase <python.list@tim.thechases.com> - 2014-02-11 12:51 -0600
Re: Flag control variable Peter Otten <__peter__@web.de> - 2014-02-11 19:51 +0100
Re: Flag control variable luke.geelen@gmail.com - 2014-02-11 11:01 -0800
Re: Flag control variable luke.geelen@gmail.com - 2014-02-11 11:06 -0800
Re: Flag control variable Gary Herron <gary.herron@islandtraining.com> - 2014-02-11 11:26 -0800
Re: Flag control variable Tim Chase <python.list@tim.thechases.com> - 2014-02-11 13:28 -0600
Re: Flag control variable luke.geelen@gmail.com - 2014-02-11 11:54 -0800
Re: Flag control variable Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-02-11 20:02 +0000
Re: Flag control variable Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2014-02-11 21:14 +0200
Re: Flag control variable Gary Herron <gary.herron@islandtraining.com> - 2014-02-11 11:20 -0800
Re: Flag control variable Gary Herron <gary.herron@islandtraining.com> - 2014-02-11 10:55 -0800
Re: Flag control variable luke.geelen@gmail.com - 2014-02-11 10:59 -0800
Re: Flag control variable Gary Herron <gary.herron@islandtraining.com> - 2014-02-11 11:09 -0800
Re: Flag control variable Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-02-11 19:08 +0000
Re: Flag control variable luke.geelen@gmail.com - 2014-02-11 11:55 -0800
Re: Flag control variable Gary Herron <gary.herron@islandtraining.com> - 2014-02-11 12:19 -0800
Re: Flag control variable luke.geelen@gmail.com - 2014-02-11 13:18 -0800
Re: Flag control variable Gary Herron <gary.herron@islandtraining.com> - 2014-02-11 15:47 -0800
Re: Flag control variable luke.geelen@gmail.com - 2014-02-11 21:09 -0800
Re: Flag control variable Dave Angel <davea@davea.name> - 2014-02-12 00:23 -0500
Re: Flag control variable luke.geelen@gmail.com - 2014-02-12 07:32 -0800
Re: Flag control variable Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-02-12 15:42 +0000
Re: Flag control variable Dave Angel <davea@davea.name> - 2014-02-12 13:51 -0500
Re: Flag control variable Alain Ketterlin <alain@dpt-info.u-strasbg.fr> - 2014-02-12 17:10 +0100
Re: Flag control variable luke.geelen@gmail.com - 2014-02-12 09:15 -0800
Re: Flag control variable Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-02-12 20:46 -0500
csiph-web