Re: Variables in a loop, Newby question

2013-12-27 Thread vanommen . robert
Op dinsdag 24 december 2013 17:23:43 UTC+1 schreef Jean-Michel Pichavant: > - Original Message - > > Hello, for the first time I'm trying te create a little Python > > program. (on a raspberri Pi) > > > > I don't understand the handling of variables in a loop with Python. > > > > > > Let

Re: Variables in a loop, Newby question

2013-12-27 Thread vanommen . robert
Hello everyone, I have been away for a while. I have been reading all the good advises and want to explain why I want to read the temperatures separately from the main script. It takes a long time to read out 10 temperatures. About 10 seconds. So that’s the reason why I had the idea to create a

Re: Variables in a loop, Newby question

2013-12-26 Thread Chris Angelico
On Thu, Dec 26, 2013 at 7:14 PM, Dave Angel wrote: > On Thu, 26 Dec 2013 16:41:57 +1100, Steven D'Aprano > wrote: >> >> Chris Angelico wrote: >> > Does anyone else have the vague feeling that the OP's problem > might be >> > better served by simply importing the script (thus making those > values

Re: Variables in a loop, Newby question

2013-12-26 Thread Dave Angel
On Thu, 26 Dec 2013 16:41:57 +1100, Steven D'Aprano wrote: Chris Angelico wrote: > Does anyone else have the vague feeling that the OP's problem might be > better served by simply importing the script (thus making those values > available to another Python script) than by any of these rat

Re: Variables in a loop, Newby question

2013-12-25 Thread Michael Torrie
On 12/24/2013 11:27 AM, vanommen.rob...@gmail.com wrote: > Indeed this is code what I found on the web to read temperatures from > 10 DS18B20 singlewire sensors. > > My only programming (little) experience is VBA (Excel mostly). > Definitely you'll want to learn python before you go much farther

Re: Variables in a loop, Newby question

2013-12-25 Thread Steven D'Aprano
Chris Angelico wrote: > Does anyone else have the vague feeling that the OP's problem might be > better served by simply importing the script (thus making those values > available to another Python script) than by any of these rather more > complicated theories? Damn yes! -- Steven -- https

Re: Variables in a loop, Newby question

2013-12-25 Thread Chris Angelico
On Thu, Dec 26, 2013 at 12:01 PM, Cameron Simpson wrote: > On 25Dec2013 15:27, Denis McMahon wrote: >> On Wed, 25 Dec 2013 16:42:47 +1100, Cameron Simpson wrote: >> > On 25Dec2013 02:54, Denis McMahon wrote: >> >> On Tue, 24 Dec 2013 10:27:13 -0800, vanommen.robert wrote: >> >> > In this script

Re: Variables in a loop, Newby question

2013-12-25 Thread Cameron Simpson
On 25Dec2013 15:27, Denis McMahon wrote: > On Wed, 25 Dec 2013 16:42:47 +1100, Cameron Simpson wrote: > > On 25Dec2013 02:54, Denis McMahon wrote: > >> On Tue, 24 Dec 2013 10:27:13 -0800, vanommen.robert wrote: > >> > In this script i want to read the temperatures and make them > >> > available t

Re: Variables in a loop, Newby question

2013-12-25 Thread Denis McMahon
On Wed, 25 Dec 2013 16:42:47 +1100, Cameron Simpson wrote: > On 25Dec2013 02:54, Denis McMahon wrote: >> On Tue, 24 Dec 2013 10:27:13 -0800, vanommen.robert wrote: >> > In this script i want to read the temperatures and make them >> > available to other scripts. [...] >> If you want this process

Re: Variables in a loop, Newby question

2013-12-25 Thread Peter Otten
vanommen.rob...@gmail.com wrote: > Indeed this is code what I found on the web to read temperatures from 10 > DS18B20 singlewire sensors. > > My only programming (little) experience is VBA (Excel mostly). > > avgtemperatures = [] is indeed from the original code where this line > > 'avgtemperat

Re: Variables in a loop, Newby question

2013-12-25 Thread Larry Hudson
On 12/24/2013 08:07 AM, vanommen.rob...@gmail.com wrote: [snip...] x = 1 while x <> 10 var x = x x = x + 1 [snip...] Besides the other valid answers you have received, I want to add one other minor nit. The symbol <> for unequal is deprecated -- it's better to use != instead.

Re: Variables in a loop, Newby question

2013-12-24 Thread Cameron Simpson
On 25Dec2013 02:54, Denis McMahon wrote: > On Tue, 24 Dec 2013 10:27:13 -0800, vanommen.robert wrote: > > In this script i want to read the temperatures and make them available > > to other scripts. [...] > If you want this process to provide data to other processes, you might > want to look at u

Re: Variables in a loop, Newby question

2013-12-24 Thread Denis McMahon
On Tue, 24 Dec 2013 10:27:13 -0800, vanommen.robert wrote: > In this script i want to read the temperatures and make them available > to other scripts. The "global" keyword doesn't do that. "global" is used inside a function definition in python to tell the function that it is working with a gl

Re: Variables in a loop, Newby question

2013-12-24 Thread Dave Angel
On Tue, 24 Dec 2013 09:54:48 -0800 (PST), vanommen.rob...@gmail.com wrote: You should always start by mentioning python version and o.s. import time global Sens_Raw1, Sens_Raw2, Sens_Raw3, Sens_Raw4, Sens_Raw5, Sens_Raw6, Sens_Raw7, Sens_Raw8, Sens_Raw9, Sens_Raw10 The global statement make

Re: Variables in a loop, Newby question

2013-12-24 Thread vanommen . robert
Indeed this is code what I found on the web to read temperatures from 10 DS18B20 singlewire sensors. My only programming (little) experience is VBA (Excel mostly). avgtemperatures = [] is indeed from the original code where this line 'avgtemperatures.append(sum(temperatures) / float(len(temper

Re: Variables in a loop, Newby question

2013-12-24 Thread Joel Goldstick
On Tue, Dec 24, 2013 at 12:54 PM, wrote: > import time > global Sens_Raw1, Sens_Raw2, Sens_Raw3, Sens_Raw4, Sens_Raw5, Sens_Raw6, > Sens_Raw7, Sens_Raw8, Sens_Raw9, Sens_Raw10 > while True: > sensorids = ["28-054c4932", "28-054c9454", > "28-054c9fca", "28-054c4401", "28-00

Re: Variables in a loop, Newby question

2013-12-24 Thread vanommen . robert
import time global Sens_Raw1, Sens_Raw2, Sens_Raw3, Sens_Raw4, Sens_Raw5, Sens_Raw6, Sens_Raw7, Sens_Raw8, Sens_Raw9, Sens_Raw10 while True: sensorids = ["28-054c4932", "28-054c9454", "28-054c9fca", "28-054c4401", "28-054dab99", "28-054cf9b4", "28-054c8a03", "

Re: Variables in a loop, Newby question

2013-12-24 Thread bob gailer
On 12/24/2013 11:07 AM, vanommen.rob...@gmail.com wrote: Hello, for the first time I'm trying te create a little Python program. (on a raspberri Pi) I don't understand the handling of variables in a loop with Python. Lets say i want something like this. x = 1 while x <> 10 var x = x

Re: Variables in a loop, Newby question

2013-12-24 Thread Peter Otten
vanommen.rob...@gmail.com wrote: > Hello, for the first time I'm trying te create a little Python program. > (on a raspberri Pi) > > I don't understand the handling of variables in a loop with Python. > > > Lets say i want something like this. > > x = 1 > while x <> 10 > var x = x > x = x + 1

Re: Variables in a loop, Newby question

2013-12-24 Thread Tobias M.
On 24.12.2013 17:07, vanommen.rob...@gmail.com wrote: Hello, for the first time I'm trying te create a little Python program. (on a raspberri Pi) I don't understand the handling of variables in a loop with Python. Lets say i want something like this. x = 1 while x <> 10 var x = x

Re: Variables in a loop, Newby question

2013-12-24 Thread Jean-Michel Pichavant
- Original Message - > Hello, for the first time I'm trying te create a little Python > program. (on a raspberri Pi) > > I don't understand the handling of variables in a loop with Python. > > > Lets say i want something like this. > > x = 1 > while x <> 10 > var x = x > x =

Re: Variables in a loop, Newby question

2013-12-24 Thread Joel Goldstick
On Tue, Dec 24, 2013 at 11:07 AM, wrote: > Hello, for the first time I'm trying te create a little Python program. > (on a raspberri Pi) > > I don't understand the handling of variables in a loop with Python. > > > Lets say i want something like this. > > x = 1 > while x <> 10 > var x = x

Variables in a loop, Newby question

2013-12-24 Thread vanommen . robert
Hello, for the first time I'm trying te create a little Python program. (on a raspberri Pi) I don't understand the handling of variables in a loop with Python. Lets say i want something like this. x = 1 while x <> 10 var x = x x = x + 1 The results must be: var1 = 1 var2 = 2