title: What is the Python equivalent of static variables inside a function?
body: <p>What is the idiomatic Python equivalent of this C/C++ code?</p>
  
  <pre class="lang-cpp prettyprint-override"><code>void foo()
  {
      static int counter = 0;
      counter++;
      printf("counter is %d\n", counter);
  }
  </code></pre>
  
  <p>specifically, how does one implement the static member at the function level, as opposed to the class level? And does placing the function into a class change anything?</p>