Background:
I have a python script to check working hours of employees. Each employee has morning and afternoon shifts, with lunch time in between, and each time they put the finger a new timestamp is recorded.
So, depending on the time of each day, there may be from zero to four timestamps in the list for that day.
The question: "How can I 'unpack' timestamps to the respective variables avoiding all this ugly, duplicated code?"
morning_entry = None
morning_leave = None
afternoon_entry = None
afternoon_leave = None
timestamps = get_timestamps()
if timestamps:
morning_entry = timestamps.pop(0)
if timestamps:
morning_leave = timestamps.pop(0)
if timestamps:
afternoon_entry = timestamps.pop(0)
if timestamps:
afternoon_leave = timestamps.pop(0)