try-finally

Workaround for python 2.4's yield not allowed in try block with finally clause

I'm stuck on python2.4, so I can't use a finally clause with generators or yield. Is there any way to work around this? I can't find any mentions of how to work around this limitation in python 2.4, and I'm not a big fan of the workarounds I've thought of (mainly involving __del__ and trying to make sure it runs within a reasonable tim...

Difference between try-finally and try-catch

What's the difference between try { fooBar(); } finally { barFoo(); } and try { fooBar(); } catch(Throwable throwable) { barFoo(throwable); // Does something with throwable, logs it, or handles it. } I like the second version better because it gives me access to the Throwable. Is there any logical difference or a pref...

Should I put a try-finally block after every Object.Create?

I have a general question about best practice in OO Delphi. Currently, I put try-finally blocks anywhere I create an object to free that object after usage (to avoid memory leaks). E.g.: aObject := TObject.Create; try aOBject.AProcedure(); ... finally aObject.Free; end; instead of: aObject := TObject.Create; aObject.AProcedure(...

understanding the finally block

I've written seven test cases for understanding the behavior of finally block. Can you guys explain the logic behind how finally works?? package core; public class Test { public static void main(String[] args) { new Test().testFinally(); } public void testFinally() { System.out.println("One = " + tryOne()); System.out.println...

getting asynchronous socket error 10049 even if i use try..except

when ever i run my program(outside the debugger/ide) i get error asynchronous socket error 10049, am i not supposed to recieve a message dialoge : ''error''? see my code below begin try ClientSocket1.open; except showmessage('error'); end; end; what am i doing wrong? ...

throw-catch logic

try { try { throw new Exception("From Try"); } catch { throw new Exception("From Catch"); } finally { throw new Exception("From Finally"); } } catch (Exception ex) { Console.WriteLine(ex.Message); } The above code's output is: From Finally. Why it's not From Catch? -or- ...