Coding style and else statements

Ben Finney bignose+hates-spam at benfinney.id.au
Thu Aug 31 09:52:31 EDT 2006


Pete Forman <pete.forman at westerngeco.com> writes:

> Ben Finney <bignose+hates-spam at benfinney.id.au> writes:
>
> > 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?
>
> There will always be more potential return points in languages that
> support exceptions.

I was specifically referring to 'return' points, i.e. points in the
function where a 'return' statement appears.

In the example to which I responded, the function had multiple
'return' statements, and an 'assert' to aid in finding out when none
of the return statements was hit. I'm making the point that if that
effort is being taken anyway, it's more readable to allow the reader
to see only *one* explicit return at the end, and not write any more
in the first place.

-- 
 \     "Ours is a world where people don't know what they want and are |
  `\    willing to go through hell to get it."  -- Donald Robert Perry |
_o__)                                                          Marquis |
Ben Finney




More information about the Python-list mailing list