[Tutor] am I missing another simpler structure?

Alan Gauld alan.gauld at freenet.co.uk
Fri Dec 17 00:46:54 CET 2004

> I far prefer the Brian's version, because it lets me set a single 
> breakpoint while I'm debugging, and I can look at the return value 
> before returning it, 

In most debiggers(including Pythons) you can still do that 
with a boolean condition provided the condition does not 
itself contain a function call. Simply evaluate the condition 
in the debugger - eg using the print command.

But if the condition has a function in it this is not wise 
since the function may have side-effects so every time you 
call it may result in a different result.

So my advise is to ony use the 

return <condition>

trick on side-effect free simple expressions, otherwise 
go with the more verbose options.

Same applies to the C ?: operator or the python shortcuts 
using 'and' and 'or'...

Alan G.

More information about the Tutor mailing list