Python Forum

Full Version: a list of lists of lists of ...
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
a list is passed to a function. that list may be empty or contain some number of items. the items at some depth will be all the same type. the items may be lists just like the top list (may be empty, will have all items be the same type, may contain lists). multiple lists at the same level may have different sizes (including possibly empty).

given a depth number (0 means the top) i want to collect all items. 0 gets the given list itself. 1 gets all the items in the given list. the result is to be an iterator. if the requested depth exceeds the existing depth, raise an exception.