I'm writing a game in Python with the Pygame2 multimedia library, but I'm more accustomed to developing games with ActionScript 3. In AS3, I don't think it was possible to store an object in a static variable, because static variables were initialized before objects could be instantiated.
However, in Python, I'm not sure if this holds true. Can I store an object instance in a Python class variable? When will it be instantiated? Will one be instantiated per class or per instance?
class Test:
counter = Counter() # A class variable counts its instantiations
def __init__(self):
counter.count() # A method that prints the number of instances of Counter
test1 = Test() # Prints 1
test2 = Test() # Prints 1? 2?