Productivity/Timer app that uses twilio to send SMS-reminders I wrote a timer app in python using both twilio and the timer module; sends an sms to my phone after a certain amount of time has passed. While it works without a doubt, I wanted to gather some ideas/opinions on how to improve my program for efficiency, readability, etc...

I'm open to all suggestions.

import time
from twilio.rest import Client

client = Client("KEY", "KEY")

work_time = 20 * 60
break_time = 5 * 60

def _timer(workState = True):
    messageBody = ["Time to work", "Time to break"]
    if workState == True:
        client.messages.create(to="MYNUMBER", from_="TWILIONUMBER", body="Time To Work!")
        time.sleep(work_time)
        _timer(not workState)
    else:
        client.messages.create(to="MYNUMBER", from_="TWILIONUMBER", body="Time To Break!")
        time.sleep(break_time)
        _timer(not workState)
_timer(False)


Please note: Several values have been changed for privacy sake (e.g. MYNUMBER, TWILIONUMBER, KEY)
Ways of improving:


work_time and break_time as constant values deserve to be defined as CONSTANTS
_timer function:


workState should be renamed to work_state to follow naming conventions
messageBody = ["Time to work", "Time to break"] is not actually used (can be eliminated)
if workState == True: is just a verbose version of if workState:
both conditional branches if/else have the same common statement _timer(not workState) but differ in action name work/break and delay time work_time/break_time.The whole condition can be restructured to reduce repetitive code and move the common statement(s) out





The final optimized version:

import time
from twilio.rest import Client

client = Client("KEY", "KEY")

WORK_TIME = 20 * 60
BREAK_TIME = 5 * 60


def _timer(work_state=True):
    if work_state:
        action, delay_time = 'work', WORK_TIME
    else:
        action, delay_time = 'break', BREAK_TIME

    client.messages.create(to="MYNUMBER", from_="TWILIONUMBER", 
                           body=f"Time To {action.title()}!")
    time.sleep(delay_time)
    _timer(not work_state)


_timer(False)