Moving to functional programming

Paul Rubin http
Tue Jul 15 22:52:26 EDT 2008


James Fassett <james at reggieband.com> writes:
> tuple_list = (
>     ('John', 'Doe'),
>     ('Mark', 'Mason'),
>     ('Jeff', 'Stevens'),
>     ('Bat', 'Man')
>   )
> # the final functional way
> [result_list, _] = zip(*tuple_list)

That's really ugly IMO.  I'd use:

  result_list = list(x for (x,y) in tuple_list)

I don't like square-bracket listcomps because they leak the index
variables to the outside.



More information about the Python-list mailing list