Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #65931 > unrolled thread

Flag control variable

Started byluke.geelen@gmail.com
First post2014-02-11 09:29 -0800
Last post2014-02-12 20:46 -0500
Articles 13 on this page of 33 — 10 participants

Back to article view | Back to comp.lang.python


Contents

  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

Page 2 of 2 — ← Prev page 1 [2]


#65951

FromMark Lawrence <breamoreboy@yahoo.co.uk>
Date2014-02-11 19:08 +0000
Message-ID<mailman.6697.1392145806.18130.python-list@python.org>
In reply to#65946
On 11/02/2014 18:59, luke.geelen@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 you can do for our language.

Mark Lawrence

---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com

[toc] | [prev] | [next] | [standalone]


#65958

Fromluke.geelen@gmail.com
Date2014-02-11 11:55 -0800
Message-ID<d5c035dd-1f66-4383-b4e2-079e539c267c@googlegroups.com>
In reply to#65931
hey, i got another problem now,
if i use the imterpreter to do 3 * 4 it gives twelve
the script gives 3333?
any tips

[toc] | [prev] | [next] | [standalone]


#65960

FromGary Herron <gary.herron@islandtraining.com>
Date2014-02-11 12:19 -0800
Message-ID<mailman.6703.1392149965.18130.python-list@python.org>
In reply to#65958
On 02/11/2014 11:55 AM, luke.geelen@gmail.com wrote:
> hey, i got another problem now,
> if i use the imterpreter to do 3 * 4 it gives twelve
> the script gives 3333?
> any tips

 >>> 3*4
12

 >>> "3"*4
'3333'


Multiplying two integers produces the result you expect.

Multiplying a *string* by an integer is what you are doing. (And it just 
repeats the string a number of times -- not what you want.)

Your code used to have int(...) to convert the string supplied by 
sys.argv into integers.  What happened to them?

Gary Herron




[toc] | [prev] | [next] | [standalone]


#65961

Fromluke.geelen@gmail.com
Date2014-02-11 13:18 -0800
Message-ID<a06b09f2-b233-46a1-a7d5-048511adb753@googlegroups.com>
In reply to#65960
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)

[toc] | [prev] | [next] | [standalone]


#65963

FromGary Herron <gary.herron@islandtraining.com>
Date2014-02-11 15:47 -0800
Message-ID<mailman.6704.1392162473.18130.python-list@python.org>
In reply to#65961
On 02/11/2014 01:18 PM, luke.geelen@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 or 1
>
> Luke
>
> (PS thanks for the quick help)

That question does not make sense to me.  Yes, you can set c=1 in your 
program, or zero if that's what you want, but this can't be the question 
you are really trying to ask.

[toc] | [prev] | [next] | [standalone]


#65996

Fromluke.geelen@gmail.com
Date2014-02-11 21:09 -0800
Message-ID<68f27949-e613-476b-9227-5a86e4f4df91@googlegroups.com>
In reply to#65963
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

[toc] | [prev] | [next] | [standalone]


#65998

FromDave Angel <davea@davea.name>
Date2014-02-12 00:23 -0500
Message-ID<mailman.6727.1392182391.18130.python-list@python.org>
In reply to#65996
 luke.geelen@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. append ("0")

But of course there are lots of other things you need to check, 
 so consider all of them at the same time. 

-- 
DaveA

[toc] | [prev] | [next] | [standalone]


#66046

Fromluke.geelen@gmail.com
Date2014-02-12 07:32 -0800
Message-ID<9335871e-e4a5-4bdf-92de-72ac7f20a722@googlegroups.com>
In reply to#65998
Op woensdag 12 februari 2014 06:23:14 UTC+1 schreef Dave Angel:
> luke.geelen@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. append ("0")
> 
> 
> 
> But of course there are lots of other things you need to check, 
> 
>  so consider all of them at the same time. 
> 
> 
> 
> -- 
> 
> DaveA

then i keep getting IndexError: list index out of range
anyway to prevent it and just set the value to 0?

[toc] | [prev] | [next] | [standalone]


#66048

FromMark Lawrence <breamoreboy@yahoo.co.uk>
Date2014-02-12 15:42 +0000
Message-ID<mailman.6761.1392219909.18130.python-list@python.org>
In reply to#66046
On 12/02/2014 15:32, luke.geelen@gmail.com wrote:
> Op woensdag 12 februari 2014 06:23:14 UTC+1 schreef Dave Angel:
>> luke.geelen@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. append ("0")
>>
>>
>>
>> But of course there are lots of other things you need to check,
>>
>>   so consider all of them at the same time.
>>
>>
>>
>> --
>>
>> DaveA
>
> then i keep getting IndexError: list index out of range
> anyway to prevent it and just set the value to 0?
>

Please find a semi-decent tool to use or always follow the instructions 
for how to remove the double line spacing when using gg, thanks.

-- 
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.

Mark Lawrence

---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com

[toc] | [prev] | [next] | [standalone]


#66072

FromDave Angel <davea@davea.name>
Date2014-02-12 13:51 -0500
Message-ID<mailman.6776.1392230902.18130.python-list@python.org>
In reply to#66046
 luke.geelen@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 to fix it? And do I turn left or back up at the
 corner?


-- 
DaveA

[toc] | [prev] | [next] | [standalone]


#66050

FromAlain Ketterlin <alain@dpt-info.u-strasbg.fr>
Date2014-02-12 17:10 +0100
Message-ID<878utg5n2b.fsf@dpt-info.u-strasbg.fr>
In reply to#65996
luke.geelen@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.

[toc] | [prev] | [next] | [standalone]


#66060

Fromluke.geelen@gmail.com
Date2014-02-12 09:15 -0800
Message-ID<36d112ba-7e78-4514-a917-424afb270cac@googlegroups.com>
In reply to#66050
Op woensdag 12 februari 2014 17:10:36 UTC+1 schreef Alain Ketterlin:
> luke.geelen@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.

thanks a lot

[toc] | [prev] | [next] | [standalone]


#66131

FromDennis Lee Bieber <wlfraed@ix.netcom.com>
Date2014-02-12 20:46 -0500
Message-ID<mailman.6814.1392256007.18130.python-list@python.org>
In reply to#65996
On Tue, 11 Feb 2014 21:09:02 -0800 (PST), luke.geelen@gmail.com declaimed
the following:

>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

	I suspect it will be beyond your current skill level, but you are
rapidly approaching the point where you might want to study the
documentation for the argparse module (or the earlier optparse module --
it's a steeplechase... getopt losing out to optparse which in turn loses to
argparse))
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
    wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

[toc] | [prev] | [standalone]


Page 2 of 2 — ← Prev page 1 [2]

Back to top | Article view | comp.lang.python


csiph-web