[Tutor] knowing when a list is updated by a thread

Vaibhav.bhawsar whatpot at gmail.com
Wed Apr 23 08:26:38 CEST 2008


i have this code to print every new element in a list only when the list
length changes (while the list is updated by a thread running elsewhere)...I
was wondering if there is a pythonic way to do this? how does one know when
there is a new element in the list?

prevlength = 0
    while geoCode.running:
        places = geoCode.getResults() #returns a list with most up to date
elements..the list grows as the thread that updates it
        if len(places) > prevlength:
            print places[prevlength]
            prevlength = len(places)


thank you!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20080423/48347c6b/attachment.htm>


More information about the Tutor mailing list