I know Python supports object-oriented structure, which uses dot notation. However, I feel confused about the code below where dot notation appears in a function definition with no class defined. Is that some feature defined as function attributes [I guess] in Python?
def count(f):
def counted(*args):
counted.call_count += 1
return f(*args)
counted.call_count = 0
return counted
The second question: is there an alternative that the code above could be rewritten using the nonlocal statement instead of the dot notation to record the call_count?