0
dateSTR = datetime.datetime.now().strftime("%H:%M:%S" ) 
if dateSTR >= ("20:42:10"):
   do function
else:
    # do something useful till this time

this if statement will do function when time of day is >= 8:42:10 pm. Not complaining, It's a nice time trigger in Python as far as I can see. Just unsure how valid it is.

Main issue : Not sure how two strings can be equal, unequal or greater in this case.
AND: Is there a better, more correct way for novice hobbyist to code an "ALARM" at a TOD? (Not wanting to try to use the numerical values of time, Event / TOD is based on a string value of time.)

mAd
  • 29
  • 3
  • 2
    There are sort of two questions here, and both are duplicates. Take your pick. How are strings compared using less than and greater than in Python? [Lexicographically.](https://stackoverflow.com/questions/4806911/string-comparison-technique-used-by-python) Run a function at a particular time: [1](https://stackoverflow.com/questions/11523918/python-start-a-function-at-given-time) [2](https://stackoverflow.com/questions/15088037/python-script-to-do-something-at-the-same-time-every-day) [3](https://stackoverflow.com/questions/5677853/how-to-run-a-python-script-at-a-specific-times) – Two-Bit Alchemist Sep 03 '16 at 02:55
  • Thanks. lexicographical ordering helped in understanding "why". – mAd Sep 03 '16 at 13:39
  • Yes, three maybe two questions: a little sleepy/ – mAd Sep 03 '16 at 13:39

0 Answers0