Skip to content
Timer
Profile icon
Knecinedit

Timer that tracks time in seconds, minutes, hours, days, and weeks.

You are viewing a single comment. View All
Profile icon
[deleted]

why are there globals?

Profile icon
Knecinedit

@TaylorLiang
I don't quite remember, but I think 'variables were referenced before assignment', so I made every variable global. Twice.

Profile icon
[deleted]

@Knecinedit
why though? Global variables are a bad practice

Profile icon
TobyS

@TaylorLiang
Why are globals bad?

Profile icon
[deleted]

@TobyS
They lead to errors and bugs, that are often difficult to debug or fix

Profile icon
TobyS

@TaylorLiang
Well I guess if your entire code was dependent on 1 global yeah but a few globals in short code shouldn't be a problem

Profile icon
[deleted]

@TobyS
reeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee

Profile icon
TobyS

@TaylorLiang
Haha thats what I was expecting

Profile icon
[deleted]

@TobyS
reeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee

Profile icon
TobyS

@TaylorLiang
Exactly

Profile icon
[deleted]

@TobyS
screeching

Profile icon
Knecinedit

@TaylorLiang
What do you suggest as an alternative? If a variable is necessary in multiple functions, it can't just sit there and remain local. That'll cause an error itself.

Profile icon
[deleted]

@Knecinedit
make it a perameter in the function
so main(time, x1,x2,x3, *etc)

Profile icon
[deleted]

@TaylorLiang
if you have lots of parameters, that can serve the same purpose within the function, it would make more sense to list it as an *args. Just a tip. Don't know if it applies here though.

Profile icon
Knecinedit

@TaylorLiang
There we go, I have removed the globals. I never had any bugs or errors with them, but I appreciate anything clean up my code. Thank you!