workmad3 wrote:
I think jamie actually wants a day-range, so it would split just the string 'Mon-Thurs' into the list ['Mon', 'Tues', 'Weds', 'Thurs'].
I don't think there is a nice way of doing it in python. I'd suggest writing one and submitting it to a python library site, as it can then be expanded and possibly included into a nice advanced python date library at some point
oh I see... 'mon-thu' is the string, not jamie's shorthand
Well it sounds too specific to have it's own function. You could perhaps make a function to crop the full list.
sourcestr ='mon-tue-wed-thu-fri'
1. Use sourcestr.split() to take the source string to a source list
= ['mon', 'tue', 'wed', 'thu', 'fri]
2. then create a subsequence of the source list from elements i to j
sourcestr.split()[i:j]
3. we need to determine i and j using
str.find(sub[, start[, end]])
i = sourcestr.split().find('mon')
j = sourcestr.split().find('thu')
So
I don't know how to define the python function, but would this work?
Code:
function dayrange(start, end)
sourcestr ='mon-tue-wed-thu-fri'
dayrange = sourcestr.split()[sourcestr.split().find(start) : sourcestr.split().find(end)]
end function
this is a crazy language
