(newbie) N-uples from list of lists

Alex Martelli aleax at mail.comcast.net
Thu Nov 24 04:25:47 CET 2005


bonono at gmail.com <bonono at gmail.com> wrote:

> Out of curiousity, is "recursion" the desirable way(or is it pythonic
> way) ? How would one do it in the imperative way ?

For an inherently recursive problem (as this one appears to be), the
traditional alternative to recursion is maintaining your own LIFO stack.
If (with all the obvious refactorings) things gets messy, ah well, at
least you've broken free of the recursion limit;-).  [[ Sometimes
(rarely) things don't get messy, and then you find out that the problem
wasn't really "inherently recursive";-) ]]

An example of recursion elimination in Python can be found at
<http://mail.python.org/pipermail/python-list/2002-January/082481.html>


Alex



More information about the Python-list mailing list