
On Thu, Nov 27, 2014 at 9:24 AM, Stefano Borini < stefano.borini@ferrara.linux.it> wrote:
On Thu, Nov 27, 2014 at 11:30:40PM +1100, Chris Angelico wrote:
You could abuse try/finally for this purpose.
try: whatever you need to do finally: my_widget.setFocus()
I thought about this solution, but I am concerned about communication of intent. Using the try communicates to a code reader that the code inside is expected to throw, which is not the case.
If there is absolutely no possibility of an exception, you don't need any special construct. Just use
whatever you need to do my_widget.setFocus() Otherwise, you are tacitly agreeing that an exception *might* occur, so try/finally is not misleading.
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/