[Tutor] seek and slice a range in a list of dates

washakie washakie at gmail.com
Sat Feb 9 21:55:37 CET 2008


I'm using the code below to select the closest dates in a dictionary of
dates, to selected dates (Tstart, Tend)... Now, I need to get all the dates
(slice) from the dictionary in between the two dates TstartNew and TendNew.
Basically, I need to know what the 'index' is for them in the in the
dictionay dates_dt. How can I get that information out of the lambda
functions? does python have a 'find' function??


for i in range(len(dates_list)):

TstartNew=sorted(dates_dt.values(),key=lambda d: abs(Tstart - d))[0]
TendNew=sorted(dates_dt.values(), key=lambda d: abs(Tend -d))[0]

View this message in context: http://www.nabble.com/seek-and-slice-a-range-in-a-list-of-dates-tp15389997p15389997.html
Sent from the Python - tutor mailing list archive at Nabble.com.

More information about the Tutor mailing list