We’ve looked at file level static variables, so now let’s see what happens when you put them in a function.
If you declare a static variable at function level (i.e. inside an normal function, not a class method), then you are creating a variable that will:
a) be instantiated the first time the function is actually called, and
b) retain its value after the function exits.
The variable is only accessible inside the function it is declared in.