Why it's not ok for variables to be global but it's ok for functions?

Viewed 77

I was writing some Python code and, as usual, I try to make my functions small and give them a clear name (although sometimes a little too long). I get to the point where there are no global variables and everything a function needs is passed to it.

But I thought, in this case, every function has access to any other function. Why not limit their access to other functions just like we limit the access to other variables.

I was thinking to use nested functions but that implies closures and that's even worse for my purpose.

I was also thinking about using objects and I think this is the point of OOP, although it'll be a little too much boilerplate in my case.

Has anyone got this problem on her/his mind and what's the solution.

3 Answers
Related