sharing/swapping items between lists

Aahz aahz at pythoncraft.com
Sat Apr 11 19:10:17 CEST 2009


In article <4fd78ac3-ba83-456b-b768-3a0043548565 at f19g2000vbf.googlegroups.com>,
Ross  <ross.jett at gmail.com> wrote:
>
>I'm trying to design an iterator that produces two lists. The first
>list will be a list of unique pairings and the second will be a list
>of items that weren't used in the first list. After each round, the
>items that weren't used in the round before will get put back in and
>the second list will be populated with unique items. 

How do you specify what goes into the first list?  Based on your
description, I would have expected that the output from the first
iteration would be

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

Regardless of the actual algorithm, if you are returning items one at a
time and maintaining state in a computation, you probably want to use a
generator.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

Why is this newsgroup different from all other newsgroups?



More information about the Python-list mailing list