extracting tuples from a list

Aahz Maruch aahz at netcom.com
Mon Jul 3 10:28:59 EDT 2000


In article <3960A07F.7240F23B at teleatlas.com>,
Michael Husmann  <michael.husmann at teleatlas.com> wrote:
>
>Is there a simple way to extract two elements from a list
>that has a size of 2n? I going this way:
>
>while list:
>	i, k = list.pop(0), list.pop(0)
>
>Is there a better solution?

How was the list created?  Can you create it in such a way that each
element is a tuple?  Example:

list = []
for line in file.readlines()
  list.append(FunctionThatReturnsATuple(line))
for item in list:
  (i,k) = item
--
                      --- Aahz (Copyright 2000 by aahz at netcom.com)

Androgynous poly kinky vanilla queer het    <*>     http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6

The best way to get information on Usenet is not to ask a question,
but to post the wrong information.  --Aahz



More information about the Python-list mailing list