[Tutor] Circular approach to a dictionary structure

Hugo González Monteverde hugonz-lists at h-lab.net
Fri Oct 28 22:33:28 CEST 2005


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, then I'd think of a list, 
and using some modulus when iterating.

Can you explain more of what you are trying to do?


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

More information about the Tutor mailing list