"Carl Banks" <[EMAIL PROTECTED]> writes: > Ben Finney wrote: > > "Carl Banks" <[EMAIL PROTECTED]> writes: > > > def foo(thing): > > > if thing: > > > return thing+1 > > > else: > > > return -1 > > > assert False > > > > To my eyes, that's less readable than, and has no benefit over, > > the following: > > > > def foo(thing): > > if thing: > > result = thing+1 > > else: > > result = -1 > > return result > > For this example, yes. Actually I'd probably never do it in this > particular case. What I mean in general is some rare times > (especially when logic is complex) I prefer to use a redundant > control statement that renders something non-reachable; then I use > assert False there.
That's the readability problem I'm referring to. Why not ensure that there is one return point from the function, so the reader doesn't have to remind themselves to look for hidden return points? -- \ "Dyslexia means never having to say that you're ysror." -- | `\ Anonymous | _o__) | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list