I\'m using an OrderedDict to random access a list, but now want the next
item in the list from the one that I have:
foo = OrderedDict([(\'apple\', 4
Reworked from your code, this way I guess would be a little better:
import collections as co
import datetime as dt
import itertools as it
foo = co.OrderedDict([
(dt.date(2000,1,1), 4),
(dt.date(2000,5,23), 3),
(dt.date(2000,10,1), 2),
(dt.date(2000,12,31), 1)
])
today = dt.date(2000,1,30)
fooiter = it.dropwhile(lambda d: d <= today, foo)
print next(fooiter)
print list(fooiter)
Basically having iterator at the right place is already enough.
Would be cool to start iteration from any position, but not sure if-how possible. Needs some thought.