omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Day of Week Issue

    Pythonista
    2
    3
    1336
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Dann239
      Dann239 last edited by

      So I have a problem. I've thought and thought and googled and googled.

      If today is Saturday... I want to set up a list (or possibly dictionary) whereas the order will follow as Saturday, Sunday, Monday, etc. this needs to reapply every time I run the script. That list will end with Friday if I ran it on a Saturday...

      I can obviously get the weekday using datetime. How do I apply that? How do I simplify the instruction to create the list?

      1 Reply Last reply Reply Quote 0
      • ccc
        ccc last edited by

        import datetime as dt
        now = dt.datetime.now()
        the_daze = [(now + dt.timedelta(days=i)).strftime('%A') for i in xrange(7)]
        print(the_daze)
        
        1 Reply Last reply Reply Quote 0
        • Dann239
          Dann239 last edited by

          Thank you, ccc.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          Powered by NodeBB Forums | Contributors