[Tutor] Circular approach to a dictionary structure

Tim Johnson tim at johnsons-web.com
Fri Oct 28 23:43:45 CEST 2005


* Hugo González Monteverde <hugonz-lists at h-lab.net> [051028 12:51]:
> Hi,
> 
> There may be, but I do not understand what is it exactly what you are 
> trying to do.
> 
> If you're trying to implement a circular something that goes back to the 
> first element after iterating the last one, 

  Yes. You are correct!
  tj
  
> then I'd think of a list, 
> and using some modulus when iterating.
 
> Can you explain more of what you are trying to do?
> 
> 
> Hugo
> 
> Tim Johnson wrote:
> > Hello:
> > 
> > # I have the following dictionary:
> > next_phases = {"open":"review","review":"write","write":"open"}
> > 
> > # a 'phase is extracted by
> > next_phase = next_phases[self.phase
> > 
> > Note that the value for each of the first keys is the key for
> > the next item, and that the value for the last key is the *first* key.
> > 
> > Is there a different way to do this? Works fine for me this way, but
> > I'm just curious about an alternative, :-) expecially if it is better.
> > 
> > thanks
> > tim
> > 
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor

-- 
Tim Johnson <tim at johnsons-web.com>
      http://www.alaska-internet-solutions.com


More information about the Tutor mailing list