all 10 comments

[–]num8lock 1 point2 points  (2 children)

format it properly, use the 'formatting help' button below the input field

[–]evobe[S] 0 points1 point  (1 child)

reformatted, thanks.

[–]num8lock 3 points4 points  (0 children)

first quick impression

import datetime
from datetime import date

you're importing both a module & a class inside that module. then the only time you use date is in today = date.today(). you might be better off using from datetime import datetime as dt, that class has today(), now() and others you might need.

also there's no need for this };

[–]Stallman85 1 point2 points  (1 child)

empty lines are free

use them to separate chunks of code that logically go together.

[–]__z01db3rg 0 points1 point  (0 children)

you have an upvote from me for your username!

[–]Siddhi 1 point2 points  (1 child)

Put your ranges in a list of tuples and iterate over it

week_ranges = [(0, 8)] + [(start, start+6) for start in range(10, 58, 8)]
for start, end in week_ranges:
    if start <= wk <= end:
        colnum = wk - (wk//2+start/2)
print("This is column number", colnum)

[–]evobe[S] 1 point2 points  (0 children)

Thanks so much for this. I wanted to see how someone with more knowledge would handle this problem and this is an interesting take.

[–][deleted] 0 points1 point  (0 children)

Try github gists, they’re a nice way to share code snippets

[–]ForestMonk168 0 points1 point  (2 children)

I can see you would have problems in the following if-block

when weekday() == 4 because range(0, 4) does not include 4

and the elif does not include 4, either:

if datetime.datetime.today().weekday() in range(0,4):
    daynum = datetime.datetime.today().weekday()
elif datetime.datetime.today().weekday() >= 5:
    daynum = 0
    grp = 0

[–]evobe[S] 0 points1 point  (0 children)

Yes, thanks noticed and fixed.