On Sat, Jan 17, 2015 at 9:20 AM, Gregory Ewing
<greg.ew...@canterbury.ac.nz> wrote:
> The only thing I would change is to wrap it all up
> in a top-level function that takes care of creating
> the result set and returning it.
>
> def walk(obj):
>   res = set()
>   _walk(obj, res)
>   return res
>
> def _walk(obj, res):
>   ...

Point of style: I like to put these kinds of helpers _above_ the
corresponding public functions, to maintain a general policy of
Define-Before-Use. Tends to make code easier to read; the first
reference to a function name is its definition, then all usage comes
after that. It's not always possible, of course (eg mutual recursion),
but in simple cases like this, it's easy enough.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to