3 ms·
Interestingly, Python has the "with" statement for this basic genre of operation (executing a block of code while some particular resource is held), although it
by thristian 15y ago
Interestingly, Python has the "with" statement for this basic genre of operation (executing a block of code while some particular resource is held), although it doesn't require that the third, "undo" step be automatically derived from the first step - it's just a protocol where a 'start' and 'end' method are called on the object representing the resource.
It sure makes it easy to be sure you're closing your file handles/database connections/mutexes, though.
- heyitsnick 15y agoI find it very handy with GUI programming under python too. with wait_cursor(wxwindow): ... change cursor to hourglass whilst process runs... I have similar context processors for locking controls or other temporary GUI changes