Welcome to CCP
lets get started !
Hello you,
We left off with going some more on classes,
today, we'll talk about Inheritance in python3,
we studied classes and they were like blueprints,
example:
we humans are mammals, that means if we create a class Mammal and a class Human, we would make sure that all properties and methods are inherited from Mammals to humans,
like mammals give birth to young one and so humans also,
mammals generally have 4-chambered heart and so we humans have,
all similar properties are inherited by humans
have a look this:
Here,
You can see that however the Human class has an empty body,
it inherited all the properties and methods from the the parent or base class (in this case Mammal),
It inherited even the __init__ method or constructor,
However,
we override the function like this:
python makes overriding as simple as defining a new function,
we can also override properties,
like this:
You can do much more than these examples,
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Remember this and you are good to go
Possibilities are endless,
You can even deploy a server through python3,
Want to Know how ?
Tutorial coming up on the how to in the next part !
Comments
Post a Comment