[Tutor] Circular approach to a dictionary structure

Tim Johnson tim at johnsons-web.com
Fri Oct 28 22:10:39 CEST 2005


# 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.


Tim Johnson <tim at johnsons-web.com>

More information about the Tutor mailing list