flow control / get next / filter?

Discussion in 'Python' started by Ken Godee, Oct 29, 2003.

  1. Ken Godee

    Ken Godee Guest

    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
     
    Ken Godee, Oct 29, 2003
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Deniz Bahar
    Replies:
    2
    Views:
    492
    Andrey Tarasevich
    Mar 9, 2005
  2. Jack Dowson
    Replies:
    0
    Views:
    469
    Jack Dowson
    May 7, 2007
  3. =?ISO-8859-2?Q?Miros=B3aw?= Makowiecki

    Reading of file by next of map file and by next of file descriptor.

    =?ISO-8859-2?Q?Miros=B3aw?= Makowiecki, Jul 10, 2007, in forum: C++
    Replies:
    1
    Views:
    809
    Alf P. Steinbach
    Jul 10, 2007
  4. Tad McClellan
    Replies:
    3
    Views:
    161
    Edward Wijaya
    May 13, 2004
  5. Liora
    Replies:
    5
    Views:
    686
    Tad McClellan
    Jan 12, 2007
Loading...

Share This Page