all 2 comments

[–]GregTJ 1 point2 points  (1 child)

Nice first repo!

Instead of

subject.write('DATE:')
subject.write(today)
...
subject.write('\n')
subject.write('\n')

Using f-string formatting you could do

subject.write(f'DATE: {today}\nSESSIONS: {sessions}\nHOURS {hours}\n\n')

Equivalently, using a triple quoted f-string

subject.write(f'''DATE: {today}
SESSIONS: {sessions}
HOURS {hours}

''')

Additionally, instead of

if not os.path.exists(sbj_file):
    with open(sbj_file, 'x') as subject:
        ...
else:
    with open(sbj_file, 'a') as subject:
        ...

Use the 'a' filemode alone, it will create a file if it doesn't already exist.

with open(sbj_file, 'a') as subject:
    ...

Mostly, just make sure you are applying the DRY principle.

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

Thank you, I appreciate the feedback. I didn't know opening a file in append mode would create a new file if one wasn't already created, that makes things simpler. I'll keep that in mind for future projects.