I know there are other ways to do this, but I am want to use match
here.
In this snip, the break
piece matches for all integers > 0, but I want it to match only n
' I'm using the cast because it wasn't working without it. Not working with it either but...
#times is a simple list of python datetimes
n=len(times)
for i,time in enumerate(times) :
print(f'{i} {time}')
match int(i):
case 0 :
print('continuing')
continue
case int(n) :
print(f'breaking for {i}')
#break
case __ :
period = times[i+1] - time
print(period)
source https://stackoverflow.com/questions/74182057/python-match-confusion-about-match-testing
Comments
Post a Comment