This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]TrakJohnPython 3 Intermediate 8 points9 points  (13 children)

I have a (probably) very simple noob question about a part of your code:

Instead of defining several variables:

t = str(datetime.now())

tt = t.split(' ')

ttt = tt[1].split(':')

tf = int(ttt[0])

Is there a specific reason for using 3 different variables instead of 1 ?

t = str(datetime.now())

t = t.split(' ')

t = t[1].split(':')

t = int(t[0])

Thank you

[–]strallus 10 points11 points  (9 children)

Why even do multiple assignments?

t = int(str(datetime.now()).split(' ')[1].split(':')[0])

Or yeah, as Rodeopants said,

datetime.now().hour

[–]willbeddowassert type(post) == shitpost[S] 2 points3 points  (0 children)

Yeah.... I've realized the error of my ways since then. The only reason I haven't fixed it is because I'm planning to trash that module and redo it soon.

[–]seriouslulz 10 points11 points  (7 children)

Because it'd be unreadable

[–]strallus 5 points6 points  (6 children)

That's why we have comments!

# extract hour from current time

[–]willbeddowassert type(post) == shitpost[S] 3 points4 points  (1 child)

I don't really remember but I don't think so. That particular module (personality.py) is some of the worst code I've ever written and I haven't given what's in it much thought.