<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>On Aug 15, 2015, at 19:15, Wes Turner <<a href="mailto:wes.turner@gmail.com">wes.turner@gmail.com</a>> wrote:</div><div><br></div><blockquote type="cite"><div><p dir="ltr"><br>
On Aug 15, 2015 9:06 PM, <<a href="mailto:random832@fastmail.us">random832@fastmail.us</a>> wrote:<br>
><br>
><br>
><br>
> On Sat, Aug 15, 2015, at 22:02, Wes Turner wrote:<br>
> > On Aug 15, 2015 8:57 PM, <<a href="mailto:random832@fastmail.us">random832@fastmail.us</a>> wrote:<br>
> > ><br>
> > > On Sat, Aug 15, 2015, at 18:54, Wes Turner wrote:<br>
> > > > Thanks! Hadn't been aware that there is a flatten() func in stdlib.<br>
> > ><br>
> > > You should be aware that this will flatten _any_ list or tuple elements<br>
> > > inside the elements, and it is gone in python 3.<br>
> ><br>
> > So it would then flatten e.g. strings without flinching<br>
><br>
> No, a string isn't a tuple or a list.<br>
><br>
> The point is it will turn (1, 2, [3, (4, 5), 6, [7, 8, [9, 10]]]) into<br>
> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]<br>
><br>
> So if you have [[(1, 2), (1, 2)], [(3, 4), (3, 4)]] it will become [1,<br>
> 2, 1, 2, 3, 4, 3, 4] while the mapmany idea you originally discussed,<br>
> and the solutions other people have given with itertools chain, would<br>
> give [(1, 2), (1, 2), (3, 4), (3, 4)]<br>
><br>
> Look for yourself, the source code is pretty understandable:<br>
><br>
> def flatten(seq):<br>
>     l = []<br>
>     for elt in seq:<br>
>         t = type(elt)<br>
>         if t is tuple or t is list:<br>
>             for elt2 in flatten(elt):<br>
>                 l.append(elt2)<br>
>         else:<br>
>             l.append(elt)<br>
>     return l<br>
><br>
> You can see it recursively calls flatten on every tuple or list element.</p>
<p dir="ltr">Got it. So there is no forwardports.flatten in py3k?</p></div></blockquote><div>Why would you expect a forward port of an undocumented function, especially one that trivial?</div><div><br></div><div>Also, given that flatten doesn't do what you want here, and there's also a stdlib function (chain) that does what you want?</div><div><br></div><br></body></html>