
July 17, 2009
9:25 a.m.
Sometimes I use helper functions to make things easier to read. However, I don't like unnecessary function calls since they are expensive in Python compared to other languages. Still I might do this: def foo(x): def bar(y): ... return ... #something depending on y ... return bar(z) If I had a "where" clause I could write: def foo(x): ... return y where: #compute y Using "where" would have the advantage of avoiding a function call, though I suppose it wouldn't save (much) stack space since it needs a new scope anyway. I see the "where" clause as a useful way to abstract a section of code to keep the high level in view, then break it down as you go.