What is the idiomatic Python equivalent of this C/C++ code?
void foo() { static int counter = 0; counter++;
One could also consider:
def foo(): try: foo.counter += 1 except AttributeError: foo.counter = 1
Reasoning:
if