fork download
  1. print("Now defining class 'A'...")
  2.  
  3. class A:
  4.  
  5. # define any initialization method here, name is irrelevant:
  6. def __my_class_constructor():
  7. print("--> class initialized!")
  8.  
  9. # this is the normal constructor, just to compare:
  10. def __init__(self):
  11. print("--> instance created!")
  12.  
  13. # do whatever you want to initialize the class (e.g. call our method from above)
  14. __my_class_constructor()
  15.  
  16. print("Now creating an instance object 'a' of class 'A'...")
  17.  
  18. a = A()
Success #stdin #stdout 0.02s 9984KB
stdin
Standard input is empty
stdout
Now defining class 'A'...
--> class initialized!
Now creating an instance object 'a' of class 'A'...
--> instance created!