Statement orders

jepler at unpythonic.net jepler at unpythonic.net
Sun Oct 2 16:54:50 EDT 2005


> would it be advisable to guard against this with something like this?
> 
> def perform_longrunning_calculation():
>      if not app.busy:
>          app.busy = 1
[...]
By using that kind of construct, instead of using update_idletasks(), 
you force all code to be aware of and manage the app.busy flag.

Another difference is that with the original code changed to use
update_idletasks(), perform_longrunning_calculation *will* be called
twice, the second time after the first one completes.  With your code,
it will be called once if the second keypress comes within one second, and
twice if called after one second is up. (though a second update before setting
busy back to false will make it be called only once)

So in also depends on what you want your application to do in these cases.

Jeff
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20051002/b5c31913/attachment.sig>


More information about the Python-list mailing list