[Tutor] (no subject)

Jeff Peery jeffpeery at yahoo.com
Wed Dec 1 00:10:10 CET 2004


that will work! thanks.
 
just for reference, how do variables pass between functions and nested functions?

Liam Clarke <cyresse at gmail.com> wrote:
Hi, 

Do you need to use the threading module? Or are you using solely the timer?

You could do a -

import time

while 1:
time.sleep(30)
dataBack=update()
if dataBack:
#process data

That would be an infinite loop, and would rely on update returning
None or similar if no update had occurred.

I hope that helps in a small way.

Regards,

Liam Clarke

On Tue, 30 Nov 2004 14:04:45 -0800 (PST), Jeff Peery
wrote:
> 
> hello again, 
> 
> I am thoroughly confused. I am using Timer from the threading module. I want
> to check a specific file every few minutes to see if it has been altered (I
> do this by checking the size of the file using stat) if it hasn't then I do
> nothing, if it has then I attempt to read the file, grab all the new
> numerical data and update a graph on my computer. 
> 
> this file I am reading holds liquid volumetric flow rate measurement data
> and the python code I am writing is to be used as a statistical process
> control. basically I watch the results from the measurements by watching a
> particular file for updates, when an update occurs I grab the data do some
> more stats, then update my graphs that show on my desktop. 
> 
> the timer I used is a class, so I defined a new object (I think thats the
> right word) as: 
> 
> myTimer = Timer(30.0, Update) 
> 
> where the timer runs every 30 seconds and Update is a function that checks
> if the file has been altered and if so then it updates my graphs. I then
> start the timer: 
> 
> myTimer.start() 
> 
> I am confused by two things: 
> 1) I want my timer to restart every 30 seconds. as it shows above it will go
> just one time. If I put this in a while loop, will the while loop loop
> through the start command faster than 30 second intervals or will it wait
> for the timer to execute the Update function before calling timer.start()
> again? 
> 2) I am also confused about how variables are handled when I have multiple
> and nested functions. for example, I would like to initiate the Update
> function every 30 seconds and I want the Update funtion to return any new
> data. how can I return something from a function when the function is called
> from a timer? I cannot do an assignment statement from within the
> definnition of myTimer? or do I even need to return the data? if I create a
> variable in the update function is it available in my main function? I am
> not sure how python handles variables that are defined in different
> functions. 
> 
> thank you very much for spending the time to help me, I appreciate it! 
> 
> Jeff 
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
> 
> 
> 


-- 
'There is only one basic human right, and that is to do as you damn well please.
And with it comes the only basic human duty, to take the consequences.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20041130/3eeed30f/attachment.htm


More information about the Tutor mailing list