Grabbing previous iteration in a dict
Paul Rubin
http
Fri May 9 05:48:21 EDT 2008
dannywebster at googlemail.com writes:
> I have a dictionary of which i'm itervalues'ing through, and i'll be
> performing some logic on a particular iteration when a condition is
> met with trusty .startswith('foo'). I need to grab the previous
> iteration if this condition is met. I can do something with an extra
> var to hold every iteration while iterating, but this is hacky and not
> elegant.
You cannot rely on the elements of a dictionary being in any
particular order (dicts are internally hash tables), so the above
is almost certainly ont what you want.
More information about the Python-list
mailing list