Storing variables temporarily during static functions?

I’ve heard that using static variables is bad practice, but I’m trying to make a static ‘library’ where in one function I set a variable, then in the second function I use that variable as a sort of constant and then that’s all it’ll do, what I have in mind is something like this

static var constant : int

static function setConstant(i : int)
    constant = i;

static function doMaths(a : int, e : int)
    return a*(constant+e)

so then in some other script I can just go DoMathsGood.setContant(4) and whatever since “DoMathsGood” won’t be attached to a GameObject which is why I’m making it all static, the reason for this is I’m building a File IO Library that I want to be able to call from any script in the game, so would what I have work in theory?

Using unprotected global and/or static variables is bad practice for various reasons, including racing conditions when using concurrently (two parts of your code want to access it at the same time) or making your code more coupled ( read more at Global Variables Are Bad.You probably want to encapsulate this in a Singleton, a commonly used pattern to deal with these situations. Singletons in Unity.

Having said that, your code will probably work, and if you do not have multiple threads, there is not a major reason why this might not work. Just keep in mind that the keyword static makes that variable unique across all of your program, so its value will always be shared no matter who calls it.