On Fri, Oct 3, 2014 at 8:26 PM, Bhargav Kowshik < bhargav.kows...@yahoo.com.dmarc.invalid> wrote:
> We could use what Anand talked about at Pycon India about handling the > headers in first row of a CSV.In this scenario, instead of default for > result being None and checking if None everytime, we could have the default > value an empty list. > > def flat_it(values, result=list()): > for v in values: > if isinstance(v, list): > flat_it(v, result) > else: > result.append(v) > return result > > x = [[1, 2, [3, 4, 5, 6, 7]], 4] > print x > print flat_it(x) > Thats a pitfall! Try calling flat_it once again and see what you get. Anand _______________________________________________ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers