Care to explain classmethods and abc.abstractmethod in laymen terms... Like completely dumb it down.
A real life example would be nice
For further actions, you may consider blocking this person and/or reporting abuse
Care to explain classmethods and abc.abstractmethod in laymen terms... Like completely dumb it down.
A real life example would be nice
For further actions, you may consider blocking this person and/or reporting abuse
Roseanne -
Mr. Algorithm -
aelassas -
Best Codes -
Top comments (3)
A class method is exactly what the name says: you have a class and the class has a method.
The difference between instance methods and class methods in Python is that the first ones operate on an instance of the class. Class methods operate on the class itself.
The main purpose of methods is to operate on state. Instance methods operate on the state of a single object, class methods operate on the class itself (they don't have access to the object) and they are also available to all objects of that class.
I think you can totally ignore the
abc
module in Python in the beginning (though I think you can almost always ignore it :)) unless you're interested in building contracts between callers and implementors. They might be useful in big architectures.abc.abstractmethod
basically means: "this method here is not a real implementation, I'm just saying to you that you need to override this method and provide an implementation when you use the base class I'm in".Now, this makes sense to me.
I've bookmarked this in case I need it again in future!
Thanks for the explanation, but still confused hahahahaha