Python Forum
Sending different color codes in python at certain times
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sending different color codes in python at certain times
#2
Something like this with a in_between function.
from datetime import datetime, time

def in_between(now, start, end):
    if start <= end:
        return start <= now < end
    else:
        return start <= now or now < end
Test:
>>> now = datetime.now().time()
>>> now
datetime.time(10, 39, 7, 444963)
>>> print("8 to 23" if in_between(now, time(8), time(23)) else "Some other time")
8 to 23
>>> print("8 to 23" if in_between(now, time(14), time(23)) else "Some other time")
Some other time
Reply


Messages In This Thread
RE: Sending different color codes in python at certain times - by snippsat - Jun-05-2018, 08:57 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Sending a text from Python sawtooth500 2 335 Apr-14-2024, 01:56 PM
Last Post: sawtooth500
  Turtle Star Fill Color Yellow-White Interchanging Color Effect codelab 9 1,227 Oct-25-2023, 09:09 AM
Last Post: codelab
Photo Visual studio code unable to color syntax on python interpreter tomtom 4 7,229 Mar-02-2022, 01:23 AM
Last Post: tomtom
  Sending string commands from Python to a bluetooth device Rovelin 13 9,917 Aug-31-2021, 06:40 PM
Last Post: deanhystad
  How to set LD_LIBRARY_PATH on python codes? aupres 1 8,669 Mar-25-2021, 08:49 AM
Last Post: buran
  Automating to run python script 100 times by changing parameters pmt 1 2,665 Dec-29-2020, 10:31 AM
Last Post: andydoc
  Sending Out Email via Python JoeDainton123 1 4,888 Aug-31-2020, 12:54 AM
Last Post: nilamo
  How to load log.txt directly into python codes? sparkt 6 3,100 Aug-21-2020, 03:51 PM
Last Post: sparkt
  Python sockets : Client sending to the server nico31780 0 2,428 May-17-2020, 07:56 PM
Last Post: nico31780
  problems sending BIN file with XMODEM python shaya2103 0 2,913 Nov-23-2019, 10:27 AM
Last Post: shaya2103

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020