flow control / get next / filter?

K

Ken Godee

I'm trying to figure out how to get the value of a variable
that's constantly getting updated, but only get the new
value, once it has changed.

I have a module where I register a call back to a function
in the code I'm working on. This function gets updated continuely.
ie....

x = ''
def myfunc(event)
global x
x = event

if you where to do a while loop, you would end up with something like...

while 1:
print x
if x == 'stop':
break

1,1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,

if you where to do a nested while, you would get....

while 1:
print x
while x != x:
print x
if x == 'stop':
break
if x == 'stop':
break

1,2,3,4,5

but it of coarse just spins the loop and processor loads pegs out.

If someone could point me in a direction, I'd appreciate it.
Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top