Re: Flag control variable

2014-02-12 Thread luke . geelen
Op woensdag 12 februari 2014 06:23:14 UTC+1 schreef Dave Angel: luke.gee...@gmail.com Wrote in message: Can I make it that if C = int(sys.argv[3]) But when I only enter 2 argumentvariable it sets c automaticly to 0 or 1 Why do you ask for 'automatically'? You're the

Re: Flag control variable

2014-02-12 Thread Mark Lawrence
On 12/02/2014 15:32, luke.gee...@gmail.com wrote: Op woensdag 12 februari 2014 06:23:14 UTC+1 schreef Dave Angel: luke.gee...@gmail.com Wrote in message: Can I make it that if C = int(sys.argv[3]) But when I only enter 2 argumentvariable it sets c automaticly to 0 or 1 Why do

Re: Flag control variable

2014-02-12 Thread Alain Ketterlin
luke.gee...@gmail.com writes: Can I make it that if C = int(sys.argv[3]) But when I only enter 2 argumentvariable it sets c automaticly to 0 or 1 C = int(sys.argv[3]) if len(sys.argv) 3 else 0 is one possibility. -- Alain. -- https://mail.python.org/mailman/listinfo/python-list

Re: Flag control variable

2014-02-12 Thread luke . geelen
Op woensdag 12 februari 2014 17:10:36 UTC+1 schreef Alain Ketterlin: luke.gee...@gmail.com writes: Can I make it that if C = int(sys.argv[3]) But when I only enter 2 argumentvariable it sets c automaticly to 0 or 1 C = int(sys.argv[3]) if len(sys.argv) 3 else 0 is

Re: Flag control variable

2014-02-12 Thread Dave Angel
luke.gee...@gmail.com Wrote in message: Deleting all the obnoxious doublespaced googlegroups nonsense. .. then i keep getting IndexError: list index out of range anyway to prevent it and just set the value to 0? My car makes a funny noise. What kind of coat should I wear to the dance

Flag control variable

2014-02-11 Thread luke . geelen
hello, i'd like to know how to set up a flag to change a variable, for example, i want a simple script to combine 2 numbers, sum = num + another_num print Now the sum of the numbers equals : , sum how could i make it so that if i type python ./script.py 21 41 that i get the sum of 21 and 41 ?

Re: Flag control variable

2014-02-11 Thread Larry Martell
On Tuesday, February 11, 2014, luke.gee...@gmail.com wrote: hello, i'd like to know how to set up a flag to change a variable, for example, i want a simple script to combine 2 numbers, sum = num + another_num print Now the sum of the numbers equals : , sum how could i make it so that if

Re: Flag control variable

2014-02-11 Thread Peter Otten
luke.gee...@gmail.com wrote: i'd like to know how to set up a flag to change a variable, for example, i want a simple script to combine 2 numbers, sum = num + another_num print Now the sum of the numbers equals : , sum how could i make it so that if i type python ./script.py 21 41

Re: Flag control variable

2014-02-11 Thread luke . geelen
Thanks a lot -- https://mail.python.org/mailman/listinfo/python-list

Re: Flag control variable

2014-02-11 Thread luke . geelen
when expandig the script to multiple calcs i got a problem a = 32 c = 51 sign = * File stdin, line 1 sign = * ^ SyntaxError: invalid syntax is there a way of adding * without quoting marks, because if you do it just soms the arguments --

Re: Flag control variable

2014-02-11 Thread Tim Chase
On 2014-02-11 10:16, luke.gee...@gmail.com wrote: when expandig the script to multiple calcs i got a problem a = 32 c = 51 sign = * File stdin, line 1 sign = * ^ SyntaxError: invalid syntax is there a way of adding * without quoting marks, because if you do it just

Re: Flag control variable

2014-02-11 Thread luke . geelen
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

Re: Flag control variable

2014-02-11 Thread Tim Chase
On 2014-02-11 10:37, luke.gee...@gmail.com wrote: command1 = sudo mpg321 'http://translate.google.com/translate_tts?tl=enq=%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])

Re: Flag control variable

2014-02-11 Thread Peter Otten
luke.gee...@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

Re: Flag control variable

2014-02-11 Thread luke . geelen
Op dinsdag 11 februari 2014 19:55:59 UTC+1 schreef Gary Herron: On 02/11/2014 10:37 AM, luke.gee...@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])

Re: Flag control variable

2014-02-11 Thread Gary Herron
On 02/11/2014 10:37 AM, luke.gee...@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

Re: Flag control variable

2014-02-11 Thread luke . geelen
Op dinsdag 11 februari 2014 19:51:40 UTC+1 schreef Peter Otten: luke.gee...@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

Re: Flag control variable

2014-02-11 Thread Gary Herron
On 02/11/2014 10:59 AM, luke.gee...@gmail.com wrote: 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

Re: Flag control variable

2014-02-11 Thread Mark Lawrence
On 11/02/2014 18:59, luke.gee...@gmail.com wrote: Would you please read and action this https://wiki.python.org/moin/GoogleGroupsPython to prevent us seeing the double line spaced text that I've snipped, thanks. -- My fellow Pythonistas, ask not what our language can do for you, ask what

Re: Flag control variable

2014-02-11 Thread luke . geelen
Op dinsdag 11 februari 2014 20:01:05 UTC+1 schreef luke@gmail.com: Op dinsdag 11 februari 2014 19:51:40 UTC+1 schreef Peter Otten: luke.gee...@gmail.com wrote: well i'm trying something else but no luck : #!bin/bash/python Hm.

Re: Flag control variable

2014-02-11 Thread Jussi Piitulainen
luke.gee...@gmail.com writes: when using python script.py 2 \* 2 i get Traceback (most recent call last): File math2.py, line 5, in module sign = int(sys.argv[2]) ValueError: invalid literal for int() with base 10: '*' You've mis-spelt sigh. This is not the code that you posted.

Re: Flag control variable

2014-02-11 Thread Gary Herron
On 02/11/2014 11:01 AM, luke.gee...@gmail.com wrote: when using python script.py 2 \* 2 i get Traceback (most recent call last): File math2.py, line 5, in module sign = int(sys.argv[2]) ValueError: invalid literal for int() with base 10: '*' Stop trying to guess what is going on. Print out

Re: Flag control variable

2014-02-11 Thread Gary Herron
On 02/11/2014 11:06 AM, luke.gee...@gmail.com wrote: i found it int(sys.argv[2]) should be sys.argv[2] is there a way i can do python ./script.py 3 * 3 instead of python ./script 3 \* 3 ? That's not really a Python question. The shell (as it's called) which interprets your typed command

Re: Flag control variable

2014-02-11 Thread Tim Chase
On 2014-02-11 11:06, luke.gee...@gmail.com wrote: command1 = sudo mpg321 'http://translate.google.com/translate_tts?tl=enq=%s_times%s_equals%s' 1) PLEASE either stop using Google Groups or take the time to remove the superfluous white-space you keep

Re: Flag control variable

2014-02-11 Thread luke . geelen
Op dinsdag 11 februari 2014 20:28:44 UTC+1 schreef Tim Chase: On 2014-02-11 11:06, luke.gee...@gmail.com wrote: command1 = sudo mpg321 'http://translate.google.com/translate_tts?tl=enq=%s_times%s_equals%s' 1) PLEASE either

Re: Flag control variable

2014-02-11 Thread luke . geelen
hey, i got another problem now, if i use the imterpreter to do 3 * 4 it gives twelve the script gives ? any tips -- https://mail.python.org/mailman/listinfo/python-list

Re: Flag control variable

2014-02-11 Thread Mark Lawrence
On 11/02/2014 19:54, luke.gee...@gmail.com wrote: Op dinsdag 11 februari 2014 20:28:44 UTC+1 schreef Tim Chase: 1) PLEASE either stop using Google Groups or take the time to remove the superfluous white-space you keep adding to your posts/replies For the THIRD time, would you please read

Re: Flag control variable

2014-02-11 Thread Gary Herron
On 02/11/2014 11:55 AM, luke.gee...@gmail.com wrote: hey, i got another problem now, if i use the imterpreter to do 3 * 4 it gives twelve the script gives ? any tips 3*4 12 3*4 '' Multiplying two integers produces the result you expect. Multiplying a *string* by an integer is

Re: Flag control variable

2014-02-11 Thread luke . geelen
Would it be possible to make an int(sys.argv[1]) Not needed and set value 0 ( or in another script 1) For example a = int(sys.argv[1]) b = int(sys.argv[2]) c = int(sys.argv[3]) And I run Python ./script.py 2 3 It just set c automaticly to 0 or 1 Luke (PS thanks for the quick help) --

Re: Flag control variable

2014-02-11 Thread Gary Herron
On 02/11/2014 01:18 PM, luke.gee...@gmail.com wrote: Would it be possible to make an int(sys.argv[1]) Not needed and set value 0 ( or in another script 1) For example a = int(sys.argv[1]) b = int(sys.argv[2]) c = int(sys.argv[3]) And I run Python ./script.py 2 3 It just set c automaticly to 0

Re: Flag control variable

2014-02-11 Thread luke . geelen
Can I make it that if C = int(sys.argv[3]) But when I only enter 2 argumentvariable it sets c automaticly to 0 or 1 -- https://mail.python.org/mailman/listinfo/python-list

Re: Flag control variable

2014-02-11 Thread Dave Angel
luke.gee...@gmail.com Wrote in message: Can I make it that if C = int(sys.argv[3]) But when I only enter 2 argumentvariable it sets c automaticly to 0 or 1 Why do you ask for 'automatically'? You're the programmer, write the test in the code. if len (sys.argv) == 3: sys.argv.