i currently have a result set with the following data:
((0L, datetime.date(2018, 1, 29)), (0L, datetime.date(2018, 1, 30)), (0L,
datetime.date(2018, 1, 31)), (0L, datetime.date(2018, 2, 1)))
I am trying to check if the current date has the status 0 or 1.
Currently i do this:
if checkdate():
if result_set[0] == 1:
The checkdate function checks if the currentdate is inside the list somewhere. But there i'm stuck trying to figure out if that date has the status 1 or 0. The status is the first item on the list (0l and 1L) mysql somehow adds a L after the 0 and 1.
Currently my checkdate function looks like this:
return any(d[1] == cd for d in result_set)
Would love some help!
Edit: Now, checkdate looks like this:
return next(((s,d) for (s,d) in dates if d == date), None)
entry = checkdate([x[1] for x in result_set], cd)
if entry is not None:
status 0 or 1?checkdateto return the index of the current date in the list, or -1 if it is not in the list. Then you can simply do something likeindex = checkdate(); if index >= 0 and result_set[index][0] == 1: ....dateobjects toints.