There are no magic methods for class constructors, but Python executes all code inside a class definition that does not belong to methods when parsing the class. So you can either perform your actions and assignments there directly or call a custom method of your class from there that serves as class constructor.
print("Now defining class 'A'...")
class A:
# define any initialization method here, name is irrelevant:
def __my_class_constructor():
print("--> class initialized!")
# this is the normal constructor, just to compare:
def __init__(self):
print("--> instance created!")
# do whatever you want to initialize the class (e.g. call our method from above)
__my_class_constructor()
print("Now creating an instance object 'a' of class 'A'...")
a = A()
The output will be:
Now defining class 'A'...
--> class initialized!
Now creating an instance object 'a' of class 'A'...
--> instance created!
See this code running on ideone.com