The purpose of constructors is to initialize the state of the object. init in python much behaves like a constructor in python as it initialize the state of the objects. But I read that classmethods are also used as alternative constructors. How? I am not getting this point. How classmethods acts as constructors? See the code below:
class ABC:
def __init___(self,name)
self.name=name
@classmethod
def from_string(cls,name):
return cls(name) # Here classmethod "from_string" just returns me an object.So
# How can we say that this class method act as constructor? as it
# just gives me an object. And the purpose of constructor is not
# create an object but to initialize the state of object. Please
# clarify this confusion. Thanks