On Jul 11, 12:00 pm, James Fassett <[EMAIL PROTECTED]> wrote:

> tuple_list = (
>     ('John', 'Doe'),
>     ('Mark', 'Mason'),
>     ('Jeff', 'Stevens'),
>     ('Bat', 'Man')
>   )
>
> # what I'd do in C or other procedural languages
> result_list = []
> for item in tuple_list:
>     result_list.append(item[0])

Here are some various 'functional' solutions. Pick the one that fits
your problem best:

result_list = [fn for fn,ln in tuple_list]

result_generator = (fn for fn,ln in tuple_list)

result_list = map(lambda (fn,ln): fn, result_list)

result_generator = itertools.imap(lambda (fn,ln): fn, result_list)


--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to