LangWart: Method congestion from mutate multiplicty

Tim Chase python.list at tim.thechases.com
Sun Feb 10 19:12:57 EST 2013


> > >  flatten, flattened
> > 
> > flatten is another often requested, hard to implement correctly,
> > function. The only reason that Python doesn't have a flatten is
> > that nobody can agree on precisely what it should do.
> 
> Steven, the definition of flatten (as relates to sequences) is
> very, VERY simple:
> 
>     Return a new sequence that is the result of reducing
>     a nested sequence of sequences into a single depth 
>     sequence.

What should you get if you flatten

  [[[1,2],[3,4]],[[5,6],[7,8]]]

Should the result be

  [[1,2],[3,4],[5,6],[7,8]]

or

  [1,2,3,4,5,6,7,8]

I've needed both cases, depending on the situation.

-tkc





More information about the Python-list mailing list