Re: weird try/finally behaviour

2009-04-11 Thread Aaron Brady
On Apr 10, 7:19 pm, Terry Reedy wrote: > Sylvain Thénault wrote: > > Hi there, > > > I've encountered the following behaviour which I found surprising: - > If you say 'print test()', you shoud see None printed after 'end' (at > least with 3.0) from the function falling off the end. > > The 'if Tru

Re: weird try/finally behaviour

2009-04-10 Thread Terry Reedy
Sylvain Thénault wrote: Hi there, I've encountered the following behaviour which I found surprising: def test(): ... for x in ('test', 'tests'): ... try: ... if True: ... print 'return' ... return 1 ... finally: ...

Re: weird try/finally behaviour

2009-04-10 Thread Tim Hoffman
Hi Sylvain You should have a read of the python docs, specifically on try: finally: excerpt from docs. -- When a return, break or continue statement is executed in the try suite of a try...finally statement, the finally clause is also executed `on the way out.' A continue statement is illegal in

weird try/finally behaviour

2009-04-10 Thread Sylvain Thénault
Hi there, I've encountered the following behaviour which I found surprising: >>> def test(): ... for x in ('test', 'tests'): ... try: ... if True: ... print 'return' ... return 1 ... finally: ... print 'break' ...